OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 import 'package:kernel/kernel.dart'; |
| 5 import 'dart:io'; |
| 6 |
| 7 final String usage = ''' |
| 8 Usage: serialize_bench INPUT.dill OUTPUT.dill |
| 9 |
| 10 Deserialize INPUT and write it back to OUTPUT several times, measuring |
| 11 the time it takes, including I/O time. |
| 12 '''; |
| 13 |
| 14 main(List<String> args) async { |
| 15 if (args.length != 2) { |
| 16 print(usage); |
| 17 exit(1); |
| 18 } |
| 19 Program program = loadProgramFromBinary(args[0]); |
| 20 |
| 21 String destination = args[1]; |
| 22 var watch = new Stopwatch()..start(); |
| 23 await writeProgramToBinary(program, destination); |
| 24 int coldTime = watch.elapsedMilliseconds; |
| 25 |
| 26 watch.reset(); |
| 27 int numTrials = 10; |
| 28 for (int i = 0; i < numTrials; ++i) { |
| 29 await writeProgramToBinary(program, destination); |
| 30 } |
| 31 double hotTime = watch.elapsedMilliseconds / numTrials; |
| 32 |
| 33 print('Cold time: $coldTime ms'); |
| 34 print('Hot time: $hotTime ms'); |
| 35 } |
OLD | NEW |