Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: utils/tests/string_encoding/benchmark_runner.dart

Issue 11263040: Make String.charCodes a getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 = " ".charCodes[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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 String mbPerSec = (((1E9 * sizeBytes * resultsCount()) / 162 String mbPerSec = (((1E9 * sizeBytes * resultsCount()) /
163 (1024 * 1024 * resultsNanos()))).toString(); 163 (1024 * 1024 * resultsNanos()))).toString();
164 print("${text} total time:${totalDurationMs} ms" + 164 print("${text} total time:${totalDurationMs} ms" +
165 " iterations:${totalCount}" + 165 " iterations:${totalCount}" +
166 " mean:${meanDuration} ns; ${mbPerSec} MB/sec"); 166 " mean:${meanDuration} ns; ${mbPerSec} MB/sec");
167 } 167 }
168 168
169 String _leftAlign(String s, int width) { 169 String _leftAlign(String s, int width) {
170 List<int> outCodes = []; 170 List<int> outCodes = [];
171 outCodes.insertRange(0, width, spaceChar); 171 outCodes.insertRange(0, width, spaceChar);
172 outCodes.setRange(0, Math.min(width, s.length), s.charCodes()); 172 outCodes.setRange(0, Math.min(width, s.length), s.charCodes);
173 return new String.fromCharCodes(outCodes); 173 return new String.fromCharCodes(outCodes);
174 } 174 }
175 175
176 String _rightAlign(String s, int width) { 176 String _rightAlign(String s, int width) {
177 List<int> outCodes = []; 177 List<int> outCodes = [];
178 outCodes.insertRange(0, width, spaceChar); 178 outCodes.insertRange(0, width, spaceChar);
179 outCodes.setRange(Math.max(0, width - s.length), Math.min(width, s.length), 179 outCodes.setRange(Math.max(0, width - s.length), Math.min(width, s.length),
180 s.charCodes()); 180 s.charCodes);
181 return new String.fromCharCodes(outCodes); 181 return new String.fromCharCodes(outCodes);
182 } 182 }
183 183
184 static String _stringifyDoubleAsInt(double val) { 184 static String _stringifyDoubleAsInt(double val) {
185 if (val.isInfinite || val.isNaN) { 185 if (val.isInfinite || val.isNaN) {
186 return "NaN"; 186 return "NaN";
187 } else { 187 } else {
188 return val.toInt().toString(); 188 return val.toInt().toString();
189 } 189 }
190 } 190 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 _(TestReport r) => r.printReport() : reportHandler; 450 _(TestReport r) => r.printReport() : reportHandler;
451 } 451 }
452 452
453 Function _reportHandler; 453 Function _reportHandler;
454 Function get reportHandler => _reportHandler; 454 Function get reportHandler => _reportHandler;
455 int _warmup; 455 int _warmup;
456 int _targetTimeMs; 456 int _targetTimeMs;
457 int _minSampleTimeMs; 457 int _minSampleTimeMs;
458 int _blocksize; 458 int _blocksize;
459 } 459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698