| Index: pkg/analyzer/lib/src/generated/utilities_general.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/utilities_general.dart b/pkg/analyzer/lib/src/generated/utilities_general.dart
|
| index 1ae55e6a1d3abb57865e79f728e6c8197c895f29..e62a7815e633926fe40fca86a920a24f3b26ce59 100644
|
| --- a/pkg/analyzer/lib/src/generated/utilities_general.dart
|
| +++ b/pkg/analyzer/lib/src/generated/utilities_general.dart
|
| @@ -80,6 +80,12 @@ abstract class PerformanceTag {
|
| PerformanceTag makeCurrent();
|
|
|
| /**
|
| + * Make this the current tag for the isolate, run [f], and restore the
|
| + * previous tag. Returns the result of invoking [f].
|
| + */
|
| + makeCurrentWhile(f());
|
| +
|
| + /**
|
| * Reset the total time tracked by all [PerformanceTag]s to zero.
|
| */
|
| static void reset() {
|
| @@ -114,7 +120,8 @@ class _PerformanceTagImpl implements PerformanceTag {
|
| final Stopwatch stopwatch;
|
|
|
| _PerformanceTagImpl(String label)
|
| - : userTag = new UserTag(label), stopwatch = new Stopwatch() {
|
| + : userTag = new UserTag(label),
|
| + stopwatch = new Stopwatch() {
|
| all.add(this);
|
| }
|
|
|
| @@ -136,4 +143,13 @@ class _PerformanceTagImpl implements PerformanceTag {
|
| userTag.makeCurrent();
|
| return previous;
|
| }
|
| +
|
| + makeCurrentWhile(f()) {
|
| + PerformanceTag prevTag = makeCurrent();
|
| + try {
|
| + return f();
|
| + } finally {
|
| + prevTag.makeCurrent();
|
| + }
|
| + }
|
| }
|
|
|