| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 fasta and measure its performance. | 5 /// An entrypoint used to run portions of fasta and measure its performance. |
| 6 library front_end.tool.fasta_perf; | 6 library front_end.tool.fasta_perf; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 beginImport(_) => _enterDirective(); | 192 beginImport(_) => _enterDirective(); |
| 193 beginExport(_) => _enterDirective(); | 193 beginExport(_) => _enterDirective(); |
| 194 beginPart(_) => _enterDirective(); | 194 beginPart(_) => _enterDirective(); |
| 195 | 195 |
| 196 endExport(export, semicolon) => _exitDirective(); | 196 endExport(export, semicolon) => _exitDirective(); |
| 197 endImport(import, deferred, asKeyword, semicolon) => _exitDirective(); | 197 endImport(import, deferred, asKeyword, semicolon) => _exitDirective(); |
| 198 endPart(part, semicolon) => _exitDirective(); | 198 endPart(part, semicolon) => _exitDirective(); |
| 199 | 199 |
| 200 void beginLiteralString(Token token) { | 200 void beginLiteralString(Token token) { |
| 201 if (_inDirective) { | 201 if (_inDirective) { |
| 202 var quotedString = token.value; | 202 var quotedString = token.lexeme; |
| 203 uris.add(quotedString.substring(1, quotedString.length - 1)); | 203 uris.add(quotedString.substring(1, quotedString.length - 1)); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 /// Parses every file in [files] and reports the time spent doing so. | 208 /// Parses every file in [files] and reports the time spent doing so. |
| 209 void parseFiles(Map<Uri, List<int>> files) { | 209 void parseFiles(Map<Uri, List<int>> files) { |
| 210 scanTimer = new Stopwatch(); | 210 scanTimer = new Stopwatch(); |
| 211 var parseTimer = new Stopwatch()..start(); | 211 var parseTimer = new Stopwatch()..start(); |
| 212 files.forEach((uri, source) { | 212 files.forEach((uri, source) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 /// Report that metric [name] took [time] micro-seconds to process | 287 /// Report that metric [name] took [time] micro-seconds to process |
| 288 /// [inputSize] characters. | 288 /// [inputSize] characters. |
| 289 void report(String name, int time) { | 289 void report(String name, int time) { |
| 290 var sb = new StringBuffer(); | 290 var sb = new StringBuffer(); |
| 291 var padding = ' ' * (20 - name.length); | 291 var padding = ' ' * (20 - name.length); |
| 292 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); | 292 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); |
| 293 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); | 293 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); |
| 294 sb.write(', $invSpeed ns/char'); | 294 sb.write(', $invSpeed ns/char'); |
| 295 print('$sb'); | 295 print('$sb'); |
| 296 } | 296 } |
| OLD | NEW |