| 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' show compileEntryPoint; | 5 import 'dart:math'; |
| 6 | 6 |
| 7 main(List<String> arguments) => compileEntryPoint(arguments); | 7 import 'package:front_end/src/fasta/outline.dart' as outline; |
| 8 |
| 9 import 'standard_deviation.dart'; |
| 10 |
| 11 const int iterations = const int.fromEnvironment("iterations", defaultValue: 1); |
| 12 |
| 13 main(List<String> arguments) async { |
| 14 // Timing results for each iteration |
| 15 List<double> elapseTimes = <double>[]; |
| 16 |
| 17 for (int i = 0; i < iterations; i++) { |
| 18 if (i > 0) { |
| 19 print("\n"); |
| 20 } |
| 21 |
| 22 var stopwatch = new Stopwatch()..start(); |
| 23 await outline.compile(arguments); |
| 24 stopwatch.stop(); |
| 25 |
| 26 elapseTimes.add(stopwatch.elapsedMilliseconds.toDouble()); |
| 27 } |
| 28 |
| 29 // Calculate the mean of warm runs (#4 to n) |
| 30 List<double> warmTimes = elapseTimes.sublist(3); |
| 31 double mean = average(warmTimes); |
| 32 |
| 33 // Calculate the standard deviation |
| 34 double stdDev = standardDeviation(mean, warmTimes); |
| 35 |
| 36 // Calculate the standard deviation of the mean |
| 37 double stdDevOfTheMean = standardDeviationOfTheMean(warmTimes, stdDev); |
| 38 |
| 39 print('Summary:'); |
| 40 print(' Elapse times: $elapseTimes'); |
| 41 print(' Cold start (first run): ${elapseTimes[0]}'); |
| 42 print(' Warm run average (runs #4 to #$iterations): $mean'); |
| 43 print(' Warm run standard deviation of the mean: $stdDevOfTheMean'); |
| 44 } |
| OLD | NEW |