OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 src.domain_diagnostic; | 5 library src.domain_diagnostic; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:core' hide Resource; | 9 import 'dart:core' hide Resource; |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 /// TOOD(pq): consider adding GC to remove mappings for deleted folders | 131 /// TOOD(pq): consider adding GC to remove mappings for deleted folders |
132 Map<Folder, Average> averages = new HashMap<Folder, Average>(); | 132 Map<Folder, Average> averages = new HashMap<Folder, Average>(); |
133 | 133 |
134 final AnalysisServer server; | 134 final AnalysisServer server; |
135 Sampler(this.server) { | 135 Sampler(this.server) { |
136 start(); | 136 start(); |
137 _sample(); | 137 _sample(); |
138 } | 138 } |
139 | 139 |
140 /// Get the average for the context associated with the given [folder]. | 140 /// Get the average for the context associated with the given [folder]. |
141 int getAverage(Folder folder) { | 141 num getAverage(Folder folder) { |
142 resetTimerCountdown(); | 142 resetTimerCountdown(); |
143 return averages[folder].value; | 143 return averages[folder].value; |
144 } | 144 } |
145 | 145 |
146 /// Check if we're currently sampling. | 146 /// Check if we're currently sampling. |
147 bool isSampling() => timer?.isActive ?? false; | 147 bool isSampling() => timer?.isActive ?? false; |
148 | 148 |
149 /// Reset counter. | 149 /// Reset counter. |
150 void resetTimerCountdown() { | 150 void resetTimerCountdown() { |
151 sampleCount = 0; | 151 sampleCount = 0; |
(...skipping 29 matching lines...) Expand all Loading... |
181 averages[folder] = average; | 181 averages[folder] = average; |
182 } | 182 } |
183 average.addSample(_workItemCount(context)); | 183 average.addSample(_workItemCount(context)); |
184 } | 184 } |
185 }); | 185 }); |
186 } on Exception { | 186 } on Exception { |
187 stop(); | 187 stop(); |
188 } | 188 } |
189 } | 189 } |
190 } | 190 } |
OLD | NEW |