| OLD | NEW |
| 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 library dart2js.common.tasks; | 5 library dart2js.common.tasks; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future, | 8 Future, |
| 9 Zone, | 9 Zone, |
| 10 ZoneDelegate, | 10 ZoneDelegate, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 assert(watch != null); | 197 assert(watch != null); |
| 198 return reporter.withCurrentElement(element, () => measure(action)); | 198 return reporter.withCurrentElement(element, () => measure(action)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 /// Measure the time spent in [action] (if in verbose mode) and accumulate it | 201 /// Measure the time spent in [action] (if in verbose mode) and accumulate it |
| 202 /// under a subtask with the given name. | 202 /// under a subtask with the given name. |
| 203 measureSubtask(String name, action()) { | 203 measureSubtask(String name, action()) { |
| 204 return watch == null ? action() : measureSubtaskHelper(name, action); | 204 return watch == null ? action() : measureSubtaskHelper(name, action); |
| 205 } | 205 } |
| 206 | 206 |
| 207 /// Measure the time spent in [action] (if in verbose mode) and accumulate it |
| 208 /// under a subtask with the given name. |
| 209 measureSubtaskElement(String name, Element element, action()) { |
| 210 return watch == null |
| 211 ? reporter.withCurrentElement(element, action) |
| 212 : measureSubtaskElementHelper(name, element, action); |
| 213 } |
| 214 |
| 215 /// Helper method for [measureSubtaskElement]. Don't call this directly as it |
| 216 /// assumes that [watch] isn't null. |
| 217 measureSubtaskElementHelper(String name, Element element, action()) { |
| 218 assert(watch != null); |
| 219 return reporter.withCurrentElement( |
| 220 element, () => measureSubtaskHelper(name, action)); |
| 221 } |
| 222 |
| 207 /// Helper method for [measureSubtask]. Don't call this directly as it | 223 /// Helper method for [measureSubtask]. Don't call this directly as it |
| 208 /// assumes that [watch] isn't null. | 224 /// assumes that [watch] isn't null. |
| 209 measureSubtaskHelper(String name, action()) { | 225 measureSubtaskHelper(String name, action()) { |
| 210 assert(watch != null); | 226 assert(watch != null); |
| 211 // Use a nested CompilerTask for the measurement to ensure nested [measure] | 227 // Use a nested CompilerTask for the measurement to ensure nested [measure] |
| 212 // calls work correctly. The subtasks will never themselves have nested | 228 // calls work correctly. The subtasks will never themselves have nested |
| 213 // subtasks because they are not accessible outside. | 229 // subtasks because they are not accessible outside. |
| 214 GenericTask subtask = | 230 GenericTask subtask = |
| 215 _subtasks.putIfAbsent(name, () => new GenericTask(name, compiler)); | 231 _subtasks.putIfAbsent(name, () => new GenericTask(name, compiler)); |
| 216 return subtask.measure(action); | 232 return subtask.measure(action); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 282 } |
| 267 | 283 |
| 268 /// Call this when the eventloop returns control to us. | 284 /// Call this when the eventloop returns control to us. |
| 269 void stopAsyncWallClock() { | 285 void stopAsyncWallClock() { |
| 270 if (currentAsyncTask != null) { | 286 if (currentAsyncTask != null) { |
| 271 currentAsyncTask.watch.stop(); | 287 currentAsyncTask.watch.stop(); |
| 272 } | 288 } |
| 273 asyncWallClock.stop(); | 289 asyncWallClock.stop(); |
| 274 } | 290 } |
| 275 } | 291 } |
| OLD | NEW |