| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:front_end/src/fasta/outline.dart' as outline; | 5 import 'package:front_end/src/fasta/outline.dart' show compileEntryPoint; |
| 6 | 6 |
| 7 import 'standard_deviation.dart'; | 7 main(List<String> arguments) => compileEntryPoint(arguments); |
| 8 | |
| 9 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); | |
| 10 | |
| 11 main(List<String> arguments) async { | |
| 12 // Timing results for each iteration | |
| 13 List<double> elapseTimes = <double>[]; | |
| 14 | |
| 15 for (int i = 0; i < iterations; i++) { | |
| 16 if (i > 0) { | |
| 17 print("\n"); | |
| 18 } | |
| 19 | |
| 20 var stopwatch = new Stopwatch()..start(); | |
| 21 await outline.compile(arguments); | |
| 22 stopwatch.stop(); | |
| 23 | |
| 24 elapseTimes.add(stopwatch.elapsedMilliseconds.toDouble()); | |
| 25 } | |
| 26 | |
| 27 // No summary if less than 4 iterations | |
| 28 if (elapseTimes.length < 4) { | |
| 29 return; | |
| 30 } | |
| 31 | |
| 32 // Calculate the mean of warm runs (#4 to n) | |
| 33 List<double> warmTimes = elapseTimes.sublist(3); | |
| 34 double mean = average(warmTimes); | |
| 35 | |
| 36 // Calculate the standard deviation | |
| 37 double stdDev = standardDeviation(mean, warmTimes); | |
| 38 | |
| 39 // Calculate the standard deviation of the mean | |
| 40 double stdDevOfTheMean = standardDeviationOfTheMean(warmTimes, stdDev); | |
| 41 | |
| 42 print('Summary:'); | |
| 43 print(' Elapse times: $elapseTimes'); | |
| 44 print(' Cold start (first run): ${elapseTimes[0]}'); | |
| 45 print(' Warm run average (runs #4 to #$iterations): $mean'); | |
| 46 print(' Warm run standard deviation of the mean: $stdDevOfTheMean'); | |
| 47 } | |
| OLD | NEW |