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

Unified Diff: pkg/compiler/lib/src/dart2js.dart

Issue 2865643004: dart2js: Always print input and output sizes and compile time (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/source_file_provider.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/dart2js.dart
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index a5a4deba233f91c2b537481f07096f8a108ee19b..37175e4acb53f2c664d409710f5d35b5308d1b43 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -104,6 +104,7 @@ void parseCommandLine(List<OptionHandler> handlers, List<String> argv) {
FormattingDiagnosticHandler diagnosticHandler;
Future<api.CompilationResult> compile(List<String> argv) {
+ Stopwatch wallclock = new Stopwatch()..start();
stackTraceFilePrefix = '$currentDirectory';
Uri libraryRoot = currentDirectory;
Uri out = currentDirectory.resolve('out.js');
@@ -531,11 +532,21 @@ Future<api.CompilationResult> compile(List<String> argv) {
}
writeString(
Uri.parse('$out.deps'), getDepsOutput(inputProvider.sourceFiles));
- diagnosticHandler
- .info('Compiled ${inputProvider.dartCharactersRead} characters Dart '
- '-> ${outputProvider.totalCharactersWritten} characters '
- 'JavaScript in '
- '${relativize(currentDirectory, out, Platform.isWindows)}');
+ int dartCharactersRead = inputProvider.dartCharactersRead;
+ int jsCharactersWritten = outputProvider.totalCharactersWrittenJavaScript;
+ int jsCharactersPrimary = outputProvider.totalCharactersWrittenPrimary;
+
+ print('Compiled '
+ '${_formatCharacterCount(dartCharactersRead)} characters Dart'
+ ' to '
+ '${_formatCharacterCount(jsCharactersWritten)} characters JavaScript'
+ ' in '
+ '${_formatDurationAsSeconds(wallclock.elapsed)} seconds');
+
+ diagnosticHandler.info(
+ '${_formatCharacterCount(jsCharactersPrimary)} characters JavaScript'
+ ' in '
+ '${relativize(currentDirectory, out, Platform.isWindows)}');
if (diagnosticHandler.verbose) {
String input = uriPathToNative(arguments[0]);
print('Dart file ($input) compiled to JavaScript.');
@@ -567,6 +578,28 @@ Future<api.CompilationResult> compile(List<String> argv) {
.then(compilationDone);
}
+/// Returns the non-negative integer formatted with a thousands separator.
+String _formatCharacterCount(int value, [String separator = ',']) {
+ String text = '$value';
+ // 'Insert' separators right-to-left. Inefficient, but used just a few times.
+ for (int position = text.length - 3; position > 0; position -= 3) {
+ text = text.substring(0, position) + separator + text.substring(position);
+ }
+ return text;
+}
+
+/// Formats [duration] in seconds in fixed-point format, preferring to keep the
+/// result at to below [width] characters.
+String _formatDurationAsSeconds(Duration duration, [int width = 4]) {
+ num seconds = duration.inMilliseconds / 1000.0;
+ String text;
+ for (int digits = 3; digits >= 0; digits--) {
+ text = seconds.toStringAsFixed(digits);
+ if (text.length <= width) return text;
+ }
+ return text;
+}
+
class AbortLeg {
final message;
AbortLeg(this.message);
« no previous file with comments | « no previous file | pkg/compiler/lib/src/source_file_provider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698