Chromium Code Reviews| Index: pkg/analyzer/lib/src/task/driver.dart |
| diff --git a/pkg/analyzer/lib/src/task/driver.dart b/pkg/analyzer/lib/src/task/driver.dart |
| index b725042b36fc1c5495f486aa98432c20bdb6cae0..ca4fb0a5d29810704b3a93eafbba2d15c0e3fd5d 100644 |
| --- a/pkg/analyzer/lib/src/task/driver.dart |
| +++ b/pkg/analyzer/lib/src/task/driver.dart |
| @@ -17,7 +17,7 @@ import 'package:analyzer/src/task/inputs.dart'; |
| import 'package:analyzer/src/task/manager.dart'; |
| import 'package:analyzer/task/model.dart'; |
| -final PerformanceTag workOrderMoveNextPerfTag = |
| +final PerformanceTag workOrderMoveNextPerformanceTag = |
| new PerformanceTag('WorkOrder.moveNext'); |
| /** |
| @@ -520,11 +520,25 @@ class StronglyConnectedComponent<Node> { |
| } |
| /** |
| - * A description of a single anaysis task that can be performed to advance |
| + * A description of a single analysis task that can be performed to advance |
| * analysis. |
| */ |
| class WorkItem { |
| /** |
| + * A table mapping the names of analysis tasks to the number of times each |
| + * kind of task has been performed. |
| + */ |
| + static final Map<String, int> countMap = new HashMap<String, int>(); |
| + |
| + /** |
| + * A table mapping the names of analysis tasks to stopwatches used to compute |
| + * how much time was spent between creating an item and creating (for |
| + * performing) of each kind of task |
| + */ |
| + static final Map<String, Stopwatch> stopwatchMap = |
| + new HashMap<String, Stopwatch>(); |
| + |
| + /** |
| * The context in which the task will be performed. |
| */ |
| final InternalAnalysisContext context; |
| @@ -545,6 +559,11 @@ class WorkItem { |
| final ResultDescriptor spawningResult; |
| /** |
| + * The current inputs computing stopwatch. |
| + */ |
| + Stopwatch stopwatch; |
| + |
| + /** |
| * An iterator used to iterate over the descriptors of the inputs to the task, |
| * or `null` if all of the inputs have been collected and the task can be |
| * created. |
| @@ -594,6 +613,19 @@ class WorkItem { |
| builder = null; |
| } |
| inputs = new HashMap<String, dynamic>(); |
| + // Update performance counters. |
| + { |
| + stopwatch = stopwatchMap[descriptor.name]; |
|
Brian Wilkerson
2015/10/23 16:27:11
The descriptors are long-lived and unique, so you
|
| + if (stopwatch == null) { |
| + stopwatch = new Stopwatch(); |
| + stopwatchMap[descriptor.name] = stopwatch; |
| + } |
| + stopwatch.start(); |
| + } |
| + { |
| + int count = countMap[descriptor.name]; |
| + countMap[descriptor.name] = count == null ? 1 : count + 1; |
| + } |
| } |
| @override |
| @@ -613,6 +645,7 @@ class WorkItem { |
| * Build the task represented by this work item. |
| */ |
| AnalysisTask buildTask() { |
| + stopwatch.stop(); |
| if (builder != null) { |
| throw new StateError("some inputs have not been computed"); |
| } |
| @@ -730,7 +763,7 @@ class WorkOrder implements Iterator<WorkItem> { |
| @override |
| bool moveNext() { |
| - return workOrderMoveNextPerfTag.makeCurrentWhile(() { |
| + return workOrderMoveNextPerformanceTag.makeCurrentWhile(() { |
| if (currentItems != null && currentItems.length > 1) { |
| // Yield more items. |
| currentItems.removeLast(); |
| @@ -759,7 +792,7 @@ class WorkOrder implements Iterator<WorkItem> { |
| } |
| /** |
| - * Specilaization of [CycleAwareDependencyWalker] for use by [WorkOrder]. |
| + * Specialization of [CycleAwareDependencyWalker] for use by [WorkOrder]. |
| */ |
| class _WorkOrderDependencyWalker extends CycleAwareDependencyWalker<WorkItem> { |
| /** |