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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return ((fullBlocks * blocksize) + extraReps).toInt(); | 82 return ((fullBlocks * blocksize) + extraReps).toInt(); |
83 } | 83 } |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * Report overall test performance | 88 * Report overall test performance |
89 */ | 89 */ |
90 class TestReport { | 90 class TestReport { |
91 TestReport(this.id, this.desc, this.warmup, this.results) { | 91 TestReport(this.id, this.desc, this.warmup, this.results) { |
92 spaceChar = " ".charCodes[0]; | 92 spaceChar = " ".codeUnits[0]; |
93 } | 93 } |
94 | 94 |
95 int spaceChar; | 95 int spaceChar; |
96 | 96 |
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); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 String mbPerSec = (((1E9 * sizeBytes * resultsCount()) / | 161 String mbPerSec = (((1E9 * sizeBytes * resultsCount()) / |
162 (1024 * 1024 * resultsNanos()))).toString(); | 162 (1024 * 1024 * resultsNanos()))).toString(); |
163 print("${text} total time:${totalDurationMs} ms" + | 163 print("${text} total time:${totalDurationMs} ms" + |
164 " iterations:${totalCount}" + | 164 " iterations:${totalCount}" + |
165 " mean:${meanDuration} ns; ${mbPerSec} MB/sec"); | 165 " mean:${meanDuration} ns; ${mbPerSec} MB/sec"); |
166 } | 166 } |
167 | 167 |
168 String _leftAlign(String s, int width) { | 168 String _leftAlign(String s, int width) { |
169 List<int> outCodes = []; | 169 List<int> outCodes = []; |
170 outCodes.insertRange(0, width, spaceChar); | 170 outCodes.insertRange(0, width, spaceChar); |
171 outCodes.setRange(0, Math.min(width, s.length), s.charCodes); | 171 outCodes.setRange(0, Math.min(width, s.length), s.codeUnits); |
172 return new String.fromCharCodes(outCodes); | 172 return new String.fromCharCodes(outCodes); |
173 } | 173 } |
174 | 174 |
175 String _rightAlign(String s, int width) { | 175 String _rightAlign(String s, int width) { |
176 List<int> outCodes = []; | 176 List<int> outCodes = []; |
177 outCodes.insertRange(0, width, spaceChar); | 177 outCodes.insertRange(0, width, spaceChar); |
178 outCodes.setRange(Math.max(0, width - s.length), Math.min(width, s.length), | 178 outCodes.setRange(Math.max(0, width - s.length), Math.min(width, s.length), |
179 s.charCodes); | 179 s.codeUnits); |
180 return new String.fromCharCodes(outCodes); | 180 return new String.fromCharCodes(outCodes); |
181 } | 181 } |
182 | 182 |
183 static String _stringifyDoubleAsInt(double val) { | 183 static String _stringifyDoubleAsInt(double val) { |
184 if (val.isInfinite || val.isNaN) { | 184 if (val.isInfinite || val.isNaN) { |
185 return "NaN"; | 185 return "NaN"; |
186 } else { | 186 } else { |
187 return val.toInt().toString(); | 187 return val.toInt().toString(); |
188 } | 188 } |
189 } | 189 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 _(TestReport r) => r.printReport() : reportHandler; | 449 _(TestReport r) => r.printReport() : reportHandler; |
450 } | 450 } |
451 | 451 |
452 Function _reportHandler; | 452 Function _reportHandler; |
453 Function get reportHandler => _reportHandler; | 453 Function get reportHandler => _reportHandler; |
454 int _warmup; | 454 int _warmup; |
455 int _targetTimeMs; | 455 int _targetTimeMs; |
456 int _minSampleTimeMs; | 456 int _minSampleTimeMs; |
457 int _blocksize; | 457 int _blocksize; |
458 } | 458 } |
OLD | NEW |