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

Side by Side Diff: pkg/analyzer_cli/tool/perf.dart

Issue 2410283002: skip comments in benchmark code (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /// An entrypoint used to run portions of analyzer and measure its performance. 5 /// An entrypoint used to run portions of analyzer and measure its performance.
6 library analyzer_cli.tool.perf; 6 library analyzer_cli.tool.perf;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io' show exit; 9 import 'dart:io' show exit;
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 /// Scan [source] and return the first token produced by the scanner. 182 /// Scan [source] and return the first token produced by the scanner.
183 Token tokenize(Source source) { 183 Token tokenize(Source source) {
184 scanTimer.start(); 184 scanTimer.start();
185 var contents = source.contents.data; 185 var contents = source.contents.data;
186 scanTotalChars += contents.length; 186 scanTotalChars += contents.length;
187 // TODO(sigmund): is there a way to scan from a random-access-file without 187 // TODO(sigmund): is there a way to scan from a random-access-file without
188 // first converting to String? 188 // first converting to String?
189 var scanner = new Scanner(source, new CharSequenceReader(contents), 189 var scanner = new Scanner(source, new CharSequenceReader(contents),
190 AnalysisErrorListener.NULL_LISTENER); 190 AnalysisErrorListener.NULL_LISTENER)..preserveComments = false;
191 var token = scanner.tokenize(); 191 var token = scanner.tokenize();
192 scanTimer.stop(); 192 scanTimer.stop();
193 return token; 193 return token;
194 } 194 }
195 195
196 /// Report that metric [name] took [time] micro-seconds to process 196 /// Report that metric [name] took [time] micro-seconds to process
197 /// [scanTotalChars] characters. 197 /// [scanTotalChars] characters.
198 void report(String name, int time) { 198 void report(String name, int time) {
199 var sb = new StringBuffer(); 199 var sb = new StringBuffer();
200 sb.write('$name: $time us, ${time ~/ 1000} ms'); 200 sb.write('$name: $time us, ${time ~/ 1000} ms');
201 sb.write(', ${scanTotalChars * 1000 ~/ time} chars/ms'); 201 sb.write(', ${scanTotalChars * 1000 ~/ time} chars/ms');
202 print('$sb'); 202 print('$sb');
203 } 203 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698