OLD | NEW |
1 var BenchmarkBase; | 1 var BenchmarkBase; |
2 (function(exports) { | 2 (function(exports) { |
3 'use strict'; | 3 'use strict'; |
4 class Expect extends core.Object { | 4 class Expect extends core.Object { |
5 static equals(expected, actual) { | 5 static equals(expected, actual) { |
6 if (!dart.equals(expected, actual)) { | 6 if (!dart.equals(expected, actual)) { |
7 throw `Values not equal: ${expected} vs ${actual}`; | 7 throw `Values not equal: ${expected} vs ${actual}`; |
8 } | 8 } |
9 } | 9 } |
10 static listEquals(expected, actual) { | 10 static listEquals(expected, actual) { |
11 if (expected[core.$length] != actual[core.$length]) { | 11 if (expected[core.$length] != actual[core.$length]) { |
12 throw `Lists have different lengths: ${expected[core.$length]} vs ${actu
al[core.$length]}`; | 12 throw `Lists have different lengths: ${expected[core.$length]} vs ${actu
al[core.$length]}`; |
13 } | 13 } |
14 for (let i = 0; dart.notNull(i) < dart.notNull(actual[core.$length]); i =
dart.notNull(i) + 1) { | 14 for (let i = 0; dart.notNull(i) < dart.notNull(actual[core.$length]); i =
dart.notNull(i) + 1) { |
15 Expect.equals(expected[core.$get](i), actual[core.$get](i)); | 15 Expect.equals(expected[core.$get](i), actual[core.$get](i)); |
16 } | 16 } |
17 } | 17 } |
18 fail(message) { | 18 fail(message) { |
19 throw message; | 19 throw message; |
20 } | 20 } |
21 } | 21 } |
| 22 let name$ = Symbol('name'); |
22 class BenchmarkBase extends core.Object { | 23 class BenchmarkBase extends core.Object { |
| 24 get name() { |
| 25 return this[name$]; |
| 26 } |
23 BenchmarkBase(name) { | 27 BenchmarkBase(name) { |
24 this.name = name; | 28 this[name$] = name; |
25 } | 29 } |
26 run() {} | 30 run() {} |
27 warmup() { | 31 warmup() { |
28 this.run(); | 32 this.run(); |
29 } | 33 } |
30 exercise() { | 34 exercise() { |
31 for (let i = 0; dart.notNull(i) < 10; i = dart.notNull(i) + 1) { | 35 for (let i = 0; dart.notNull(i) < 10; i = dart.notNull(i) + 1) { |
32 this.run(); | 36 this.run(); |
33 } | 37 } |
34 } | 38 } |
(...skipping 25 matching lines...) Expand all Loading... |
60 } | 64 } |
61 report() { | 65 report() { |
62 let score = this.measure(); | 66 let score = this.measure(); |
63 core.print(`${this.name}(RunTime): ${score} us.`); | 67 core.print(`${this.name}(RunTime): ${score} us.`); |
64 } | 68 } |
65 } | 69 } |
66 // Exports: | 70 // Exports: |
67 exports.Expect = Expect; | 71 exports.Expect = Expect; |
68 exports.BenchmarkBase = BenchmarkBase; | 72 exports.BenchmarkBase = BenchmarkBase; |
69 })(BenchmarkBase || (BenchmarkBase = {})); | 73 })(BenchmarkBase || (BenchmarkBase = {})); |
OLD | NEW |