| 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:developer' show | 7 import 'dart:developer' show UserTag; |
| 8 UserTag; | |
| 9 | 8 |
| 10 import '../common.dart'; | 9 import '../common.dart'; |
| 11 import '../compiler.dart' show | 10 import '../compiler.dart' show Compiler; |
| 12 Compiler; | 11 import '../elements/elements.dart' show Element; |
| 13 import '../elements/elements.dart' show | |
| 14 Element; | |
| 15 | 12 |
| 16 typedef void DeferredAction(); | 13 typedef void DeferredAction(); |
| 17 | 14 |
| 18 class DeferredTask { | 15 class DeferredTask { |
| 19 final Element element; | 16 final Element element; |
| 20 final DeferredAction action; | 17 final DeferredAction action; |
| 21 | 18 |
| 22 DeferredTask(this.element, this.action); | 19 DeferredTask(this.element, this.action); |
| 23 } | 20 } |
| 24 | 21 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 reporter.withCurrentElement(element, () => measure(action)); | 70 reporter.withCurrentElement(element, () => measure(action)); |
| 74 } | 71 } |
| 75 | 72 |
| 76 /// Measure the time spent in [action] (if in verbose mode) and accumulate it | 73 /// Measure the time spent in [action] (if in verbose mode) and accumulate it |
| 77 /// under a subtask with the given name. | 74 /// under a subtask with the given name. |
| 78 measureSubtask(String name, action()) { | 75 measureSubtask(String name, action()) { |
| 79 if (watch == null) return action(); | 76 if (watch == null) return action(); |
| 80 // Use a nested CompilerTask for the measurement to ensure nested [measure] | 77 // Use a nested CompilerTask for the measurement to ensure nested [measure] |
| 81 // calls work correctly. The subtasks will never themselves have nested | 78 // calls work correctly. The subtasks will never themselves have nested |
| 82 // subtasks because they are not accessible outside. | 79 // subtasks because they are not accessible outside. |
| 83 GenericTask subtask = _subtasks.putIfAbsent(name, | 80 GenericTask subtask = |
| 84 () => new GenericTask(name, compiler)); | 81 _subtasks.putIfAbsent(name, () => new GenericTask(name, compiler)); |
| 85 return subtask.measure(action); | 82 return subtask.measure(action); |
| 86 } | 83 } |
| 87 | 84 |
| 88 Iterable<String> get subtasks => _subtasks.keys; | 85 Iterable<String> get subtasks => _subtasks.keys; |
| 89 | 86 |
| 90 int getSubtaskTime(String subtask) => _subtasks[subtask].timing; | 87 int getSubtaskTime(String subtask) => _subtasks[subtask].timing; |
| 91 } | 88 } |
| 92 | 89 |
| 93 class GenericTask extends CompilerTask { | 90 class GenericTask extends CompilerTask { |
| 94 final String name; | 91 final String name; |
| 95 | 92 |
| 96 GenericTask(this.name, Compiler compiler) | 93 GenericTask(this.name, Compiler compiler) : super(compiler); |
| 97 : super(compiler); | |
| 98 } | 94 } |
| OLD | NEW |