Chromium Code Reviews| 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 // No summary if less than 4 iterations | |
| 30 if (elapseTimes.length < 4) { | |
|
Paul Berry
2017/03/06 20:27:40
This should be 5. We need to ensure that at least
danrubel
2017/03/09 02:01:01
Good point. Addressed in https://codereview.chromi
| |
| 31 return; | |
| 32 } | |
| 33 | |
| 34 // Calculate the mean of warm runs (#4 to n) | |
| 35 List<double> warmTimes = elapseTimes.sublist(3); | |
| 36 double mean = average(warmTimes); | |
| 37 | |
| 38 // Calculate the standard deviation | |
| 39 double stdDev = standardDeviation(mean, warmTimes); | |
| 40 | |
| 41 // Calculate the standard deviation of the mean | |
| 42 double stdDevOfTheMean = standardDeviationOfTheMean(warmTimes, stdDev); | |
| 43 | |
| 44 print('Summary:'); | |
| 45 print(' Elapse times: $elapseTimes'); | |
| 46 print(' Cold start (first run): ${elapseTimes[0]}'); | |
| 47 print(' Warm run average (runs #4 to #$iterations): $mean'); | |
| 48 print(' Warm run standard deviation of the mean: $stdDevOfTheMean'); | |
| 49 } | |
| OLD | NEW |