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

Side by Side Diff: pkg/front_end/tool/fasta_perf.dart

Issue 2884783002: Enhance DirectiveListener to collect import/exports with combinators. (Closed)
Patch Set: Add only combinator identifiers. Created 3 years, 7 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
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 helper(start); 157 helper(start);
158 } 158 }
159 159
160 /// Parse [contents] as a Dart program and return the URIs that appear in its 160 /// Parse [contents] as a Dart program and return the URIs that appear in its
161 /// import, export, and part directives. 161 /// import, export, and part directives.
162 Set<String> extractDirectiveUris(List<int> contents) { 162 Set<String> extractDirectiveUris(List<int> contents) {
163 var listener = new DirectiveListenerWithNative(); 163 var listener = new DirectiveListenerWithNative();
164 new TopLevelParser(listener).parseUnit(tokenize(contents)); 164 new TopLevelParser(listener).parseUnit(tokenize(contents));
165 return new Set<String>() 165 return new Set<String>()
166 ..addAll(listener.imports) 166 ..addAll(listener.imports.map((d) => d.uri))
167 ..addAll(listener.exports) 167 ..addAll(listener.exports.map((d) => d.uri))
168 ..addAll(listener.parts); 168 ..addAll(listener.parts);
169 } 169 }
170 170
171 class DirectiveListenerWithNative extends DirectiveListener { 171 class DirectiveListenerWithNative extends DirectiveListener {
172 @override 172 @override
173 Token handleNativeClause(Token token) => skipNativeClause(token); 173 Token handleNativeClause(Token token) => skipNativeClause(token);
174 } 174 }
175 175
176 /// Parses every file in [files] and reports the time spent doing so. 176 /// Parses every file in [files] and reports the time spent doing so.
177 void parseFiles(Map<Uri, List<int>> files) { 177 void parseFiles(Map<Uri, List<int>> files) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 /// Report that metric [name] took [time] micro-seconds to process 253 /// Report that metric [name] took [time] micro-seconds to process
254 /// [inputSize] characters. 254 /// [inputSize] characters.
255 void report(String name, int time) { 255 void report(String name, int time) {
256 var sb = new StringBuffer(); 256 var sb = new StringBuffer();
257 var padding = ' ' * (20 - name.length); 257 var padding = ' ' * (20 - name.length);
258 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); 258 sb.write('$name:$padding $time us, ${time ~/ 1000} ms');
259 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); 259 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2);
260 sb.write(', $invSpeed ns/char'); 260 sb.write(', $invSpeed ns/char');
261 print('$sb'); 261 print('$sb');
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698