OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 5 /** |
6 * The results of a single block of tests (count times run, overall time). | 6 * The results of a single block of tests (count times run, overall time). |
7 */ | 7 */ |
8 class BlockSample { | 8 class BlockSample { |
9 BlockSample(this.count, this.durationNanos); | 9 BlockSample(this.count, this.durationNanos); |
10 int count; | 10 int count; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 int resultsCount() => BlockSample._totalCount(results); | 97 int resultsCount() => BlockSample._totalCount(results); |
98 | 98 |
99 int resultsNanos() => BlockSample._totalTime(results); | 99 int resultsNanos() => BlockSample._totalTime(results); |
100 | 100 |
101 int resultsBestNanos() { | 101 int resultsBestNanos() { |
102 BlockSample best = bestBlock(results); | 102 BlockSample best = bestBlock(results); |
103 return best.durationNanos ~/ best.count; | 103 return best.durationNanos ~/ best.count; |
104 } | 104 } |
105 | 105 |
106 int resultsMeanNanos() => | 106 int resultsMeanNanos() => |
107 (BlockSample._totalTime(results) / | 107 BlockSample._totalTime(results) ~/ BlockSample._totalCount(results); |
108 BlockSample._totalCount(results)).toInt(); | |
109 | 108 |
110 int resultsWorstNanos() { | 109 int resultsWorstNanos() { |
111 BlockSample worst = worstBlock(results); | 110 BlockSample worst = worstBlock(results); |
112 return worst.durationNanos / worst.count; | 111 return worst.durationNanos / worst.count; |
113 } | 112 } |
114 | 113 |
115 int warmupBestNanos() { | 114 int warmupBestNanos() { |
116 BlockSample best = bestBlock(warmup); | 115 BlockSample best = bestBlock(warmup); |
117 return best.durationNanos / best.count; | 116 return best.durationNanos / best.count; |
118 } | 117 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 String id; | 191 String id; |
193 String desc; | 192 String desc; |
194 List<BlockSample> warmup; | 193 List<BlockSample> warmup; |
195 List<BlockSample> results; | 194 List<BlockSample> results; |
196 } | 195 } |
197 | 196 |
198 class Runner { | 197 class Runner { |
199 static bool runTest(String testId) { | 198 static bool runTest(String testId) { |
200 Options opts = new Options(); | 199 Options opts = new Options(); |
201 return opts.arguments.length == 0 || | 200 return opts.arguments.length == 0 || |
202 opts.arguments.some(_(String id) => id == testId); | 201 opts.arguments.any((String id) => id == testId); |
203 } | 202 } |
204 } | 203 } |
205 | 204 |
206 /** | 205 /** |
207 * Run traditional blocking-style tests. Tests may be run a specified number | 206 * Run traditional blocking-style tests. Tests may be run a specified number |
208 * of times, or they can be run based on performance to estimate a particular | 207 * of times, or they can be run based on performance to estimate a particular |
209 * duration. | 208 * duration. |
210 */ | 209 */ |
211 class BenchmarkRunner extends Runner { | 210 class BenchmarkRunner extends Runner { |
212 static void runCount(String id, String desc, CountTestConfig config, | 211 static void runCount(String id, String desc, CountTestConfig config, |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 _(TestReport r) => r.printReport() : reportHandler; | 449 _(TestReport r) => r.printReport() : reportHandler; |
451 } | 450 } |
452 | 451 |
453 Function _reportHandler; | 452 Function _reportHandler; |
454 Function get reportHandler => _reportHandler; | 453 Function get reportHandler => _reportHandler; |
455 int _warmup; | 454 int _warmup; |
456 int _targetTimeMs; | 455 int _targetTimeMs; |
457 int _minSampleTimeMs; | 456 int _minSampleTimeMs; |
458 int _blocksize; | 457 int _blocksize; |
459 } | 458 } |
OLD | NEW |