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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 /// Parse the full body of [source]. | 187 /// Parse the full body of [source]. |
188 parseFull(Uri uri, List<int> source) { | 188 parseFull(Uri uri, List<int> source) { |
189 var tokens = tokenize(source); | 189 var tokens = tokenize(source); |
190 Parser parser = new Parser(new _PartialAstBuilder(uri)); | 190 Parser parser = new Parser(new _PartialAstBuilder(uri)); |
191 parser.parseUnit(tokens); | 191 parser.parseUnit(tokens); |
192 } | 192 } |
193 | 193 |
194 // Note: AstBuilder doesn't build compilation-units or classes, only method | 194 // Note: AstBuilder doesn't build compilation-units or classes, only method |
195 // bodies. So this listener is not feature complete. | 195 // bodies. So this listener is not feature complete. |
196 class _PartialAstBuilder extends AstBuilder { | 196 class _PartialAstBuilder extends AstBuilder { |
197 _PartialAstBuilder(Uri uri) : super(null, null, null, null, null, true, uri); | 197 _PartialAstBuilder(Uri uri) |
| 198 : super(null, null, null, null, null, true, true, uri); |
198 | 199 |
199 // Note: this method converts the body to kernel, so we skip that here. | 200 // Note: this method converts the body to kernel, so we skip that here. |
200 @override | 201 @override |
201 finishFunction(annotations, formals, asyncModifier, body) {} | 202 finishFunction(annotations, formals, asyncModifier, body) {} |
202 } | 203 } |
203 | 204 |
204 // Invoke the fasta kernel generator for the program starting in [entryUri] | 205 // Invoke the fasta kernel generator for the program starting in [entryUri] |
205 generateKernel(Uri entryUri, | 206 generateKernel(Uri entryUri, |
206 {bool compileSdk: true, bool strongMode: false}) async { | 207 {bool compileSdk: true, bool strongMode: false}) async { |
207 // TODO(sigmund): this is here only to compute the input size, | 208 // TODO(sigmund): this is here only to compute the input size, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 /// Report that metric [name] took [time] micro-seconds to process | 246 /// Report that metric [name] took [time] micro-seconds to process |
246 /// [inputSize] characters. | 247 /// [inputSize] characters. |
247 void report(String name, int time) { | 248 void report(String name, int time) { |
248 var sb = new StringBuffer(); | 249 var sb = new StringBuffer(); |
249 var padding = ' ' * (20 - name.length); | 250 var padding = ' ' * (20 - name.length); |
250 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); | 251 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); |
251 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); | 252 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); |
252 sb.write(', $invSpeed ns/char'); | 253 sb.write(', $invSpeed ns/char'); |
253 print('$sb'); | 254 print('$sb'); |
254 } | 255 } |
OLD | NEW |