| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 dart2js and measure its performance. | 5 /// An entrypoint used to run portions of dart2js and measure its performance. |
| 6 library compiler.tool.perf; | 6 library compiler.tool.perf; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 var token = new Scanner(source).tokenize(); | 202 var token = new Scanner(source).tokenize(); |
| 203 scanTimer.stop(); | 203 scanTimer.stop(); |
| 204 return token; | 204 return token; |
| 205 } | 205 } |
| 206 | 206 |
| 207 /// Report that metric [name] took [time] micro-seconds to process | 207 /// Report that metric [name] took [time] micro-seconds to process |
| 208 /// [scanTotalChars] characters. | 208 /// [scanTotalChars] characters. |
| 209 void report(String name, int time) { | 209 void report(String name, int time) { |
| 210 var sb = new StringBuffer(); | 210 var sb = new StringBuffer(); |
| 211 sb.write('$name: $time us, ${time ~/ 1000} ms'); | 211 sb.write('$name: $time us, ${time ~/ 1000} ms'); |
| 212 sb.write(', ${scanTotalChars * 1000 ~/ time} chars/ms'); | 212 sb.write(', ${time * 1000 ~/ scanTotalChars} ns/char'); |
| 213 print('$sb'); | 213 print('$sb'); |
| 214 } | 214 } |
| 215 | 215 |
| 216 /// Listener that parses out just the uri in imports, exports, and part | 216 /// Listener that parses out just the uri in imports, exports, and part |
| 217 /// directives. | 217 /// directives. |
| 218 class DirectiveListener extends Listener { | 218 class DirectiveListener extends Listener { |
| 219 Set<String> targets = new Set<String>(); | 219 Set<String> targets = new Set<String>(); |
| 220 | 220 |
| 221 bool inDirective = false; | 221 bool inDirective = false; |
| 222 void enterDirective() { | 222 void enterDirective() { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 370 |
| 371 phase = Compiler.PHASE_RESOLVING; | 371 phase = Compiler.PHASE_RESOLVING; |
| 372 enqueuer.resolution.applyImpact(mainImpact); | 372 enqueuer.resolution.applyImpact(mainImpact); |
| 373 // Note: we enqueue everything in the program so we measure generating | 373 // Note: we enqueue everything in the program so we measure generating |
| 374 // kernel for the entire code, not just what's reachable from main. | 374 // kernel for the entire code, not just what's reachable from main. |
| 375 libraryLoader.libraries.forEach((LibraryElement library) { | 375 libraryLoader.libraries.forEach((LibraryElement library) { |
| 376 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 376 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); |
| 377 }); | 377 }); |
| 378 | 378 |
| 379 if (deferredLoadTask.isProgramSplit) { | 379 if (deferredLoadTask.isProgramSplit) { |
| 380 enqueuer.resolution.applyImpact( | 380 enqueuer.resolution |
| 381 backend.computeDeferredLoadingImpact()); | 381 .applyImpact(backend.computeDeferredLoadingImpact()); |
| 382 } | 382 } |
| 383 enqueuer.resolution.applyImpact(backend.computeHelpersImpact()); | 383 enqueuer.resolution.applyImpact(backend.computeHelpersImpact()); |
| 384 resolveLibraryMetadata(); | 384 resolveLibraryMetadata(); |
| 385 reporter.log('Resolving...'); | 385 reporter.log('Resolving...'); |
| 386 processQueue(enqueuer.resolution, mainFunction); | 386 processQueue(enqueuer.resolution, mainFunction); |
| 387 enqueuer.resolution.logSummary(reporter.log); | 387 enqueuer.resolution.logSummary(reporter.log); |
| 388 | 388 |
| 389 (reporter as CompilerDiagnosticReporter) | 389 (reporter as CompilerDiagnosticReporter) |
| 390 .reportSuppressedMessagesSummary(); | 390 .reportSuppressedMessagesSummary(); |
| 391 | 391 |
| 392 if (compilationFailed) { | 392 if (compilationFailed) { |
| 393 // TODO(sigmund): more diagnostics? | 393 // TODO(sigmund): more diagnostics? |
| 394 print("compilation failed!"); | 394 print("compilation failed!"); |
| 395 exit(1); | 395 exit(1); |
| 396 } | 396 } |
| 397 | 397 |
| 398 closeResolution(); | 398 closeResolution(); |
| 399 var program = (backend as dynamic).kernelTask.program; | 399 var program = (backend as dynamic).kernelTask.program; |
| 400 print('total libraries: ${program.libraries.length}'); | 400 print('total libraries: ${program.libraries.length}'); |
| 401 }); | 401 }); |
| 402 } | 402 } |
| OLD | NEW |