Chromium Code Reviews| Index: pkg/compiler/lib/src/compiler.dart |
| diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart |
| index 950b4258588442ed79315f5d1c4bb4e528c6c231..36ceefa63aa824407a0571070e5d24910e169a43 100644 |
| --- a/pkg/compiler/lib/src/compiler.dart |
| +++ b/pkg/compiler/lib/src/compiler.dart |
| @@ -2207,21 +2207,67 @@ class CompilerTask { |
| int get timingMicroseconds => (watch != null) ? watch.elapsedMicroseconds : 0; |
| - measure(action()) { |
| - // In verbose mode when watch != null. |
| - if (watch == null) return action(); |
| + measure(action()) => watch == null ? action() : measureZoned(action); |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
|
| + |
| + CompilerTask start() { |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
|
| CompilerTask previous = compiler.measuredTask; |
| - if (identical(this, previous)) return action(); |
| compiler.measuredTask = this; |
| if (previous != null) previous.watch.stop(); |
| watch.start(); |
| - try { |
| - return action(); |
| - } finally { |
| - watch.stop(); |
| - if (previous != null) previous.watch.start(); |
| - compiler.measuredTask = previous; |
| + return previous; |
| + } |
| + |
| + void stop(CompilerTask previous) { |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
|
| + watch.stop(); |
| + if (previous != null) previous.watch.start(); |
| + compiler.measuredTask = previous; |
| + } |
| + |
| + measureZoned(action()) { |
|
Johnni Winther
2015/11/19 10:02:18
Add doc.
|
| + assert(watch != null); |
| + if (identical(this, compiler.measuredTask)) return action(); |
| + |
| + run(Zone self, ZoneDelegate parent, Zone zone, f()) { |
| + CompilerTask previous = start(); |
| + try { |
| + return f(); |
| + } finally { |
| + stop(previous); |
| + } |
| } |
| + |
| + runUnary(Zone self, ZoneDelegate parent, Zone zone, f(arg), arg) { |
| + CompilerTask previous = start(); |
| + try { |
| + return f(arg); |
| + } finally { |
| + stop(previous); |
| + } |
| + } |
| + |
| + runBinary(Zone self, ZoneDelegate parent, Zone zone, f(a1, a2), a1, a2) { |
| + CompilerTask previous = start(); |
| + try { |
| + return f(a1, a2); |
| + } finally { |
| + stop(previous); |
| + } |
| + } |
| + |
| + return runZoned( |
| + action, zoneSpecification: new ZoneSpecification( |
| + run: run, runUnary: runUnary, runBinary: runBinary)); |
| + } |
| + |
| + measureIo(action()) => watch == null ? action() : measureIoHelper(action); |
|
Johnni Winther
2015/11/19 10:02:18
Add doc
|
| + |
| + Future measureIoHelper(Future action()) { |
| + assert(watch != null); |
| + if (identical(this, compiler.measuredTask)) return action(); |
| + CompilerTask previous = start(); |
| + return measure(action).whenComplete(() { |
| + stop(previous); |
| + }); |
| } |
| measureElement(Element element, action()) { |