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

Side by Side Diff: tools/testing/legpad/legpad.dart

Issue 9958048: display line count in legpad (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/testing/legpad/legpad.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import("dart:html", prefix:"html"); 5 #import("dart:html", prefix:"html");
6 #import('../../../lib/compiler/compiler.dart', prefix: "compiler_lib"); 6 #import('../../../lib/compiler/compiler.dart', prefix: "compiler_lib");
7 #import('../../../lib/uri/uri.dart', prefix:"uri_lib"); 7 #import('../../../lib/uri/uri.dart', prefix:"uri_lib");
8 8
9 /** 9 /**
10 * This is the entrypoint for a version of the leg compiler that 10 * This is the entrypoint for a version of the leg compiler that
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 setText("input", readAll(mainFile)); 73 setText("input", readAll(mainFile));
74 Stopwatch stopwatch = new Stopwatch.start(); 74 Stopwatch stopwatch = new Stopwatch.start();
75 runLeg(); 75 runLeg();
76 int elapsedMillis = stopwatch.elapsedInMs(); 76 int elapsedMillis = stopwatch.elapsedInMs();
77 if (output === null) { 77 if (output === null) {
78 output = "throw 'dart2js compilation error';\n"; 78 output = "throw 'dart2js compilation error';\n";
79 } 79 }
80 80
81 setText("output", output); 81 setText("output", output);
82 setText("warnings", warnings); 82 setText("warnings", warnings);
83 String timing = "generated ${output.length} characters in " + 83 int lineCount = lineCount(output);
84 String timing = "generated $lineCount lines " +
85 "(${output.length} characters) in " +
84 "${((elapsedMillis) / 1000).toStringAsPrecision(3)} seconds"; 86 "${((elapsedMillis) / 1000).toStringAsPrecision(3)} seconds";
85 setText("timing", timing); 87 setText("timing", timing);
86 } 88 }
89
90 static int lineCount(String s) {
ahe 2012/04/10 21:36:54 I feel this should be easier, but I don't know how
91 Iterable<Match> matches = "\n".allMatches(s);
92 int n = 0;
93 for (Match m in matches) {
94 n++;
95 }
96 return n;
97 }
87 98
88 void runLeg() { 99 void runLeg() {
89 uri_lib.Uri mainUri = new uri_lib.Uri.fromString(getText(MAIN_ID)); 100 uri_lib.Uri mainUri = new uri_lib.Uri.fromString(getText(MAIN_ID));
90 uri_lib.Uri libraryRoot = new uri_lib.Uri.fromString("dartdir/"); 101 uri_lib.Uri libraryRoot = new uri_lib.Uri.fromString("dartdir/");
91 List<String> compilerArgs = [ 102 List<String> compilerArgs = [
92 "--enable_type_checks", 103 "--enable_type_checks",
93 "--enable_asserts" 104 "--enable_asserts"
94 ]; 105 ];
95 106
96 // TODO(mattsh): dart2js api should be synchronous 107 // TODO(mattsh): dart2js api should be synchronous
(...skipping 21 matching lines...) Expand all
118 } 129 }
119 return element.text.trim(); 130 return element.text.trim();
120 } 131 }
121 132
122 // TODO(mattsh): should exist in standard lib somewhere 133 // TODO(mattsh): should exist in standard lib somewhere
123 static String htmlEscape(String text) { 134 static String htmlEscape(String text) {
124 return text.replaceAll('&', '&amp;').replaceAll( 135 return text.replaceAll('&', '&amp;').replaceAll(
125 '>', '&gt;').replaceAll('<', '&lt;'); 136 '>', '&gt;').replaceAll('<', '&lt;');
126 } 137 }
127 } 138 }
OLDNEW
« no previous file with comments | « no previous file | tools/testing/legpad/legpad.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698