mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:43:32 +00:00
4ff04f641b
Change-Id: Icdcc648f42393b28daf648f752e3b4d61f51aa10 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212043 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
37 lines
1 KiB
Dart
37 lines
1 KiB
Dart
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:kernel/kernel.dart';
|
|
import 'dart:io';
|
|
|
|
final String usage = '''
|
|
Usage: serialize_bench INPUT.dill OUTPUT.dill
|
|
|
|
Deserialize INPUT and write it back to OUTPUT several times, measuring
|
|
the time it takes, including I/O time.
|
|
''';
|
|
|
|
void main(List<String> args) async {
|
|
if (args.length != 2) {
|
|
print(usage);
|
|
exit(1);
|
|
}
|
|
Component component = loadComponentFromBinary(args[0]);
|
|
|
|
String destination = args[1];
|
|
var watch = new Stopwatch()..start();
|
|
await writeComponentToBinary(component, destination);
|
|
int coldTime = watch.elapsedMilliseconds;
|
|
|
|
watch.reset();
|
|
int numTrials = 10;
|
|
for (int i = 0; i < numTrials; ++i) {
|
|
await writeComponentToBinary(component, destination);
|
|
}
|
|
double hotTime = watch.elapsedMilliseconds / numTrials;
|
|
|
|
print('Cold time: $coldTime ms');
|
|
print('Hot time: $hotTime ms');
|
|
}
|