| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | 2 |
| 3 library BenchmarkBase; | 3 library BenchmarkBase; |
| 4 | 4 |
| 5 class Expect { | 5 class Expect { |
| 6 static void equals(var expected, var actual) { | 6 static void equals(var expected, var actual) { |
| 7 if (expected != actual) { | 7 if (expected != actual) { |
| 8 throw "Values not equal: $expected vs $actual"; | 8 throw "Values not equal: $expected vs $actual"; |
| 9 } | 9 } |
| 10 } | 10 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // The benchmark code. | 32 // The benchmark code. |
| 33 // This function is not used, if both [warmup] and [exercise] are overwritten. | 33 // This function is not used, if both [warmup] and [exercise] are overwritten. |
| 34 void run() {} | 34 void run() {} |
| 35 | 35 |
| 36 // Runs a short version of the benchmark. By default invokes [run] once. | 36 // Runs a short version of the benchmark. By default invokes [run] once. |
| 37 void warmup() { | 37 void warmup() { |
| 38 run(); | 38 run(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Exercices the benchmark. By default invokes [run] 10 times. | 41 // Exercises the benchmark. By default invokes [run] 10 times. |
| 42 void exercise() { | 42 void exercise() { |
| 43 for (int i = 0; i < 10; i++) { | 43 for (int i = 0; i < 10; i++) { |
| 44 run(); | 44 run(); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Not measured setup code executed prior to the benchmark runs. | 48 // Not measured setup code executed prior to the benchmark runs. |
| 49 void setup() {} | 49 void setup() {} |
| 50 | 50 |
| 51 // Not measures teardown code executed after the benchmark runs. | 51 // Not measures teardown code executed after the benchmark runs. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 }, 2000); | 80 }, 2000); |
| 81 teardown(); | 81 teardown(); |
| 82 return result; | 82 return result; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void report() { | 85 void report() { |
| 86 double score = measure(); | 86 double score = measure(); |
| 87 print("$name(RunTime): $score us."); | 87 print("$name(RunTime): $score us."); |
| 88 } | 88 } |
| 89 } | 89 } |
| OLD | NEW |