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) | 197 _PartialAstBuilder(Uri uri) : super(null, null, null, null, true, uri); |
198 : super(null, null, null, null, null, true, true, uri); | |
199 | 198 |
200 // Note: this method converts the body to kernel, so we skip that here. | 199 // Note: this method converts the body to kernel, so we skip that here. |
201 @override | 200 @override |
202 finishFunction(annotations, formals, asyncModifier, body) {} | 201 finishFunction(annotations, formals, asyncModifier, body) {} |
203 } | 202 } |
204 | 203 |
205 // Invoke the fasta kernel generator for the program starting in [entryUri] | 204 // Invoke the fasta kernel generator for the program starting in [entryUri] |
206 generateKernel(Uri entryUri, | 205 generateKernel(Uri entryUri, |
207 {bool compileSdk: true, bool strongMode: false}) async { | 206 {bool compileSdk: true, bool strongMode: false}) async { |
208 // TODO(sigmund): this is here only to compute the input size, | 207 // TODO(sigmund): this is here only to compute the input size, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 /// Report that metric [name] took [time] micro-seconds to process | 245 /// Report that metric [name] took [time] micro-seconds to process |
247 /// [inputSize] characters. | 246 /// [inputSize] characters. |
248 void report(String name, int time) { | 247 void report(String name, int time) { |
249 var sb = new StringBuffer(); | 248 var sb = new StringBuffer(); |
250 var padding = ' ' * (20 - name.length); | 249 var padding = ' ' * (20 - name.length); |
251 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); | 250 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); |
252 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); | 251 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); |
253 sb.write(', $invSpeed ns/char'); | 252 sb.write(', $invSpeed ns/char'); |
254 print('$sb'); | 253 print('$sb'); |
255 } | 254 } |
OLD | NEW |