OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of benchmark_lib; | 5 part of benchmark_lib; |
6 | 6 |
7 /** Accessors for our Singleton variables. */ | 7 /** Accessors for our Singleton variables. */ |
8 BenchmarkSuite get BENCHMARK_SUITE { | 8 BenchmarkSuite get BENCHMARK_SUITE { |
9 if (BenchmarkSuite._ONLY == null) { | 9 if (BenchmarkSuite._ONLY == null) { |
10 BenchmarkSuite._ONLY = new BenchmarkSuite._internal(); | 10 BenchmarkSuite._ONLY = new BenchmarkSuite._internal(); |
(...skipping 29 matching lines...) Expand all Loading... |
40 /** Exercices the benchmark. By default invokes [run] 10 times. */ | 40 /** Exercices the benchmark. By default invokes [run] 10 times. */ |
41 void exercise() { | 41 void exercise() { |
42 for (int i = 0; i < 10; i++) { | 42 for (int i = 0; i < 10; i++) { |
43 run(); | 43 run(); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 /** Not measured setup code executed prior to the benchmark runs. */ | 47 /** Not measured setup code executed prior to the benchmark runs. */ |
48 void setup() {} | 48 void setup() {} |
49 | 49 |
50 /** Not measures teardown code executed after the benchark runs. */ | 50 /** Not measures teardown code executed after the benchmark runs. */ |
51 void teardown() {} | 51 void teardown() {} |
52 | 52 |
53 /** | 53 /** |
54 * Measures the score for this benchmark by executing it repeately until | 54 * Measures the score for this benchmark by executing it repeately until |
55 * time minimum has been reached. | 55 * time minimum has been reached. |
56 */ | 56 */ |
57 static double measureFor(Function f, int timeMinimum) { | 57 static double measureFor(Function f, int timeMinimum) { |
58 int time = 0; | 58 int time = 0; |
59 int iter = 0; | 59 int iter = 0; |
60 Stopwatch watch = new Stopwatch(); | 60 Stopwatch watch = new Stopwatch(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 * helping readability of the scores. | 194 * helping readability of the scores. |
195 */ | 195 */ |
196 String formatScore(num value) { | 196 String formatScore(num value) { |
197 if (value > 100) { | 197 if (value > 100) { |
198 return value.toStringAsFixed(0); | 198 return value.toStringAsFixed(0); |
199 } else { | 199 } else { |
200 return value.toStringAsFixed(2); | 200 return value.toStringAsFixed(2); |
201 } | 201 } |
202 } | 202 } |
203 } | 203 } |
OLD | NEW |