| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 parser.parseUnit(tokens); | 196 parser.parseUnit(tokens); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Note: AstBuilder doesn't build compilation-units or classes, only method | 199 // Note: AstBuilder doesn't build compilation-units or classes, only method |
| 200 // bodies. So this listener is not feature complete. | 200 // bodies. So this listener is not feature complete. |
| 201 class _PartialAstBuilder extends AstBuilder { | 201 class _PartialAstBuilder extends AstBuilder { |
| 202 _PartialAstBuilder(Uri uri) : super(null, null, null, null, null, true, uri); | 202 _PartialAstBuilder(Uri uri) : super(null, null, null, null, null, true, uri); |
| 203 | 203 |
| 204 // Note: this method converts the body to kernel, so we skip that here. | 204 // Note: this method converts the body to kernel, so we skip that here. |
| 205 @override | 205 @override |
| 206 finishFunction(formals, asyncModifier, body) {} | 206 finishFunction(annotations, formals, asyncModifier, body) {} |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Invoke the fasta kernel generator for the program starting in [entryUri] | 209 // Invoke the fasta kernel generator for the program starting in [entryUri] |
| 210 // TODO(sigmund): update to use the frontend api once fasta is being hit. | 210 // TODO(sigmund): update to use the frontend api once fasta is being hit. |
| 211 generateKernel(Uri entryUri, | 211 generateKernel(Uri entryUri, |
| 212 {bool compileSdk: true, bool strongMode: false}) async { | 212 {bool compileSdk: true, bool strongMode: false}) async { |
| 213 // TODO(sigmund): this is here only to compute the input size, | 213 // TODO(sigmund): this is here only to compute the input size, |
| 214 // we should extract the input size from the frontend instead. | 214 // we should extract the input size from the frontend instead. |
| 215 scanReachableFiles(entryUri); | 215 scanReachableFiles(entryUri); |
| 216 | 216 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 /// Report that metric [name] took [time] micro-seconds to process | 256 /// Report that metric [name] took [time] micro-seconds to process |
| 257 /// [inputSize] characters. | 257 /// [inputSize] characters. |
| 258 void report(String name, int time) { | 258 void report(String name, int time) { |
| 259 var sb = new StringBuffer(); | 259 var sb = new StringBuffer(); |
| 260 var padding = ' ' * (20 - name.length); | 260 var padding = ' ' * (20 - name.length); |
| 261 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); | 261 sb.write('$name:$padding $time us, ${time ~/ 1000} ms'); |
| 262 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); | 262 var invSpeed = (time * 1000 / inputSize).toStringAsFixed(2); |
| 263 sb.write(', $invSpeed ns/char'); | 263 sb.write(', $invSpeed ns/char'); |
| 264 print('$sb'); | 264 print('$sb'); |
| 265 } | 265 } |
| OLD | NEW |