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

Unified Diff: dart/site/try/poi/poi.dart

Issue 559523003: Make timings easier to spot in output. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/poi/poi.dart
diff --git a/dart/site/try/poi/poi.dart b/dart/site/try/poi/poi.dart
index 5b80277d7235c81f54379b0ceba17dcadfdd412c..603a5a6e27cd1374703cb704369e1f30bfa573bf 100644
--- a/dart/site/try/poi/poi.dart
+++ b/dart/site/try/poi/poi.dart
@@ -98,6 +98,8 @@ bool isVerbose = false;
const bool PRINT_SCOPE_INFO =
const bool.fromEnvironment('PRINT_SCOPE_INFO', defaultValue: true);
+Stopwatch wallClock = new Stopwatch();
+
/// Iterator for reading lines from [io.stdin].
class StdinIterator implements Iterator<String> {
String current;
@@ -108,6 +110,24 @@ class StdinIterator implements Iterator<String> {
}
}
+printFormattedTime(message, int us) {
+ String m = '$message${" " * 65}'.substring(0, 60);
+ String i = '${" " * 10}${(us/1000).toStringAsFixed(3)}';
+ i = i.substring(i.length - 10);
+ print('$m ${i}ms');
+}
+
+printWallClock(message) {
+ if (!isVerbose) return;
+ if (wallClock.isRunning) {
+ print('$message');
+ printFormattedTime('--->>>', wallClock.elapsedMicroseconds);
+ wallClock.reset();
+ } else {
+ print(message);
+ }
+}
+
printVerbose(message) {
if (!isVerbose) return;
print(message);
@@ -115,6 +135,7 @@ printVerbose(message) {
main(List<String> arguments) {
poiCount = 0;
+ wallClock.start();
List<String> nonOptionArguments = [];
for (String argument in arguments) {
if (argument.startsWith('-')) {
@@ -231,11 +252,17 @@ Future parseUserInput(
api.CompilerInputProvider inputProvider,
api.DiagnosticHandler handler) {
Future repeat() {
+ printFormattedTime('--->>>', wallClock.elapsedMicroseconds);
+ wallClock.reset();
+
return prompt('Position: ').then((String positionString) {
+ wallClock.reset();
return parseUserInput(fileName, positionString, inputProvider, handler);
});
}
+ printWallClock("\n\n\nparseUserInput('$fileName', '$positionString')");
+
Uri script = Uri.base.resolveUri(new Uri.file(fileName));
if (positionString == null) return null;
int position = int.parse(
@@ -255,8 +282,9 @@ Future parseUserInput(
Future future = runPoi(script, position, inputProvider, handler);
return future.then((Element element) {
- poiCount++;
- print('Resolving took ${sw.elapsedMicroseconds}us.');
+ if (isVerbose) {
+ printFormattedTime('Resolving took', sw.elapsedMicroseconds);
+ }
sw.reset();
String info = scopeInformation(element, position);
sw.stop();
@@ -417,6 +445,9 @@ class ScriptOnlyFilter implements QueueFilter {
void processWorkItem(void f(WorkItem work), WorkItem work) {
if (work.element.library.canonicalUri == script) {
f(work);
+ printWallClock('Processed ${work.element}.');
+ } else {
+ printWallClock('Skipped ${work.element}.');
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698