OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'package:charted/charted.dart'; | 7 import 'package:charted/charted.dart'; |
8 import "package:charted/charts/charts.dart"; | 8 import "package:charted/charts/charts.dart"; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/class_ref.dart'; | 10 import 'package:observatory/src/elements/class_ref.dart'; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 link: Uris.allocationProfiler(_isolate), queue: _r.queue), | 131 link: Uris.allocationProfiler(_isolate), queue: _r.queue), |
132 new NavRefreshElement(label: 'Download', disabled: _profile == null, | 132 new NavRefreshElement(label: 'Download', disabled: _profile == null, |
133 queue: _r.queue) | 133 queue: _r.queue) |
134 ..onRefresh.listen((_) => _downloadCSV()), | 134 ..onRefresh.listen((_) => _downloadCSV()), |
135 new NavRefreshElement(label: 'Reset Accumulator', queue: _r.queue) | 135 new NavRefreshElement(label: 'Reset Accumulator', queue: _r.queue) |
136 ..onRefresh.listen((_) => _refresh(reset: true)), | 136 ..onRefresh.listen((_) => _refresh(reset: true)), |
137 new NavRefreshElement(label: 'GC', queue: _r.queue) | 137 new NavRefreshElement(label: 'GC', queue: _r.queue) |
138 ..onRefresh.listen((_) => _refresh(gc: true)), | 138 ..onRefresh.listen((_) => _refresh(gc: true)), |
139 new NavRefreshElement(queue: _r.queue) | 139 new NavRefreshElement(queue: _r.queue) |
140 ..onRefresh.listen((_) => _refresh()), | 140 ..onRefresh.listen((_) => _refresh()), |
141 new DivElement()..classes = const ['nav-option'] | 141 new DivElement()..classes = ['nav-option'] |
142 ..children = [ | 142 ..children = [ |
143 new CheckboxInputElement() | 143 new CheckboxInputElement() |
144 ..id = 'allocation-profile-auto-refresh' | 144 ..id = 'allocation-profile-auto-refresh' |
145 ..checked = _autoRefresh | 145 ..checked = _autoRefresh |
146 ..onChange.listen((_) => _autoRefresh = !_autoRefresh), | 146 ..onChange.listen((_) => _autoRefresh = !_autoRefresh), |
147 new LabelElement() | 147 new LabelElement() |
148 ..htmlFor = 'allocation-profile-auto-refresh' | 148 ..htmlFor = 'allocation-profile-auto-refresh' |
149 ..text = 'Auto-refresh on GC' | 149 ..text = 'Auto-refresh on GC' |
150 ], | 150 ], |
151 new NavNotifyElement(_notifications, queue: _r.queue) | 151 new NavNotifyElement(_notifications, queue: _r.queue) |
152 ], | 152 ], |
153 new DivElement()..classes = const ['content-centered-big'] | 153 new DivElement()..classes = ['content-centered-big'] |
154 ..children = [ | 154 ..children = [ |
155 new HeadingElement.h2()..text = 'Allocation Profile', | 155 new HeadingElement.h2()..text = 'Allocation Profile', |
156 new HRElement() | 156 new HRElement() |
157 ] | 157 ] |
158 ]; | 158 ]; |
159 if (_profile == null) { | 159 if (_profile == null) { |
160 children.addAll([ | 160 children.addAll([ |
161 new DivElement()..classes = const ['content-centered-big'] | 161 new DivElement()..classes = ['content-centered-big'] |
162 ..children = [ | 162 ..children = [ |
163 new HeadingElement.h2()..text = 'Loading...' | 163 new HeadingElement.h2()..text = 'Loading...' |
164 ] | 164 ] |
165 ]); | 165 ]); |
166 } else { | 166 } else { |
167 final newChartHost = new DivElement()..classes = const ['host']; | 167 final newChartHost = new DivElement()..classes = ['host']; |
168 final newChartLegend = new DivElement()..classes = const ['legend']; | 168 final newChartLegend = new DivElement()..classes = ['legend']; |
169 final oldChartHost = new DivElement()..classes = const ['host']; | 169 final oldChartHost = new DivElement()..classes = ['host']; |
170 final oldChartLegend = new DivElement()..classes = const ['legend']; | 170 final oldChartLegend = new DivElement()..classes = ['legend']; |
171 children.addAll([ | 171 children.addAll([ |
172 new DivElement()..classes = const ['content-centered-big'] | 172 new DivElement()..classes = ['content-centered-big'] |
173 ..children = [ | 173 ..children = [ |
174 new DivElement()..classes = const ['memberList'] | 174 new DivElement()..classes = ['memberList'] |
175 ..children = [ | 175 ..children = [ |
176 new DivElement()..classes = const ['memberItem'] | 176 new DivElement()..classes = ['memberItem'] |
177 ..children = [ | 177 ..children = [ |
178 new DivElement()..classes = const ['memberName'] | 178 new DivElement()..classes = ['memberName'] |
179 ..text = 'last forced GC at', | 179 ..text = 'last forced GC at', |
180 new DivElement()..classes = const ['memberValue'] | 180 new DivElement()..classes = ['memberValue'] |
181 ..text = _profile.lastServiceGC == null ? '---' | 181 ..text = _profile.lastServiceGC == null ? '---' |
182 : '${_profile.lastServiceGC}', | 182 : '${_profile.lastServiceGC}', |
183 ], | 183 ], |
184 new DivElement()..classes = const ['memberItem'] | 184 new DivElement()..classes = ['memberItem'] |
185 ..children = [ | 185 ..children = [ |
186 new DivElement()..classes = const ['memberName'] | 186 new DivElement()..classes = ['memberName'] |
187 ..text = 'last accumulator reset at', | 187 ..text = 'last accumulator reset at', |
188 new DivElement()..classes = const ['memberValue'] | 188 new DivElement()..classes = ['memberValue'] |
189 ..text = _profile.lastAccumulatorReset == null ? '---' | 189 ..text = _profile.lastAccumulatorReset == null ? '---' |
190 : '${_profile.lastAccumulatorReset}', | 190 : '${_profile.lastAccumulatorReset}', |
191 ] | 191 ] |
192 ], | 192 ], |
193 new HRElement(), | 193 new HRElement(), |
194 ], | 194 ], |
195 new DivElement()..classes = const ['content-centered-big'] | 195 new DivElement()..classes = ['content-centered-big'] |
196 ..children = [ | 196 ..children = [ |
197 new DivElement()..classes = const ['heap-space', 'left'] | 197 new DivElement()..classes = ['heap-space', 'left'] |
198 ..children = [ | 198 ..children = [ |
199 new HeadingElement.h2()..text = 'New Generation', | 199 new HeadingElement.h2()..text = 'New Generation', |
200 new BRElement(), | 200 new BRElement(), |
201 new DivElement()..classes = const ['memberList'] | 201 new DivElement()..classes = ['memberList'] |
202 ..children = _createSpaceMembers(_profile.newSpace), | 202 ..children = _createSpaceMembers(_profile.newSpace), |
203 new BRElement(), | 203 new BRElement(), |
204 new DivElement()..classes = const ['chart'] | 204 new DivElement()..classes = ['chart'] |
205 ..children = [newChartLegend, newChartHost] | 205 ..children = [newChartLegend, newChartHost] |
206 ], | 206 ], |
207 new DivElement()..classes = const ['heap-space', 'right'] | 207 new DivElement()..classes = ['heap-space', 'right'] |
208 ..children = [ | 208 ..children = [ |
209 new HeadingElement.h2()..text = 'Old Generation', | 209 new HeadingElement.h2()..text = 'Old Generation', |
210 new BRElement(), | 210 new BRElement(), |
211 new DivElement()..classes = const ['memberList'] | 211 new DivElement()..classes = ['memberList'] |
212 ..children = _createSpaceMembers(_profile.oldSpace), | 212 ..children = _createSpaceMembers(_profile.oldSpace), |
213 new BRElement(), | 213 new BRElement(), |
214 new DivElement()..classes = const ['chart'] | 214 new DivElement()..classes = ['chart'] |
215 ..children = [oldChartLegend, oldChartHost] | 215 ..children = [oldChartLegend, oldChartHost] |
216 ], | 216 ], |
217 new BRElement(), new HRElement() | 217 new BRElement(), new HRElement() |
218 ], | 218 ], |
219 new DivElement()..classes = const ['collection'] | 219 new DivElement()..classes = ['collection'] |
220 ..children = [ | 220 ..children = [ |
221 new VirtualCollectionElement( | 221 new VirtualCollectionElement( |
222 _createCollectionLine, | 222 _createCollectionLine, |
223 _updateCollectionLine, | 223 _updateCollectionLine, |
224 createHeader: _createCollectionHeader, | 224 createHeader: _createCollectionHeader, |
225 items: _profile.members.toList()..sort(_createSorter()), | 225 items: _profile.members.toList()..sort(_createSorter()), |
226 queue: _r.queue) | 226 queue: _r.queue) |
227 ] | 227 ] |
228 ]); | 228 ]); |
229 _renderGraph(newChartHost, newChartLegend, _profile.newSpace); | 229 _renderGraph(newChartHost, newChartLegend, _profile.newSpace); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 switch (_sortingDirection) { | 277 switch (_sortingDirection) { |
278 case _SortingDirection.ascending: | 278 case _SortingDirection.ascending: |
279 return (a, b) => getter(a).compareTo(getter(b)); | 279 return (a, b) => getter(a).compareTo(getter(b)); |
280 case _SortingDirection.descending: | 280 case _SortingDirection.descending: |
281 return (a, b) => getter(b).compareTo(getter(a)); | 281 return (a, b) => getter(b).compareTo(getter(a)); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 static Element _createCollectionLine() => | 285 static Element _createCollectionLine() => |
286 new DivElement() | 286 new DivElement() |
287 ..classes = const ['collection-item'] | 287 ..classes = ['collection-item'] |
288 ..children = [ | 288 ..children = [ |
289 new SpanElement()..classes = const ['bytes'] | 289 new SpanElement()..classes = ['bytes'] |
290 ..text = '0B', | 290 ..text = '0B', |
291 new SpanElement()..classes = const ['instances'] | 291 new SpanElement()..classes = ['instances'] |
292 ..text = '0', | 292 ..text = '0', |
293 new SpanElement()..classes = const ['bytes'] | 293 new SpanElement()..classes = ['bytes'] |
294 ..text = '0B', | 294 ..text = '0B', |
295 new SpanElement()..classes = const ['instances'] | 295 new SpanElement()..classes = ['instances'] |
296 ..text = '0', | 296 ..text = '0', |
297 new SpanElement()..classes = const ['bytes'] | 297 new SpanElement()..classes = ['bytes'] |
298 ..text = '0B', | 298 ..text = '0B', |
299 new SpanElement()..classes = const ['instances'] | 299 new SpanElement()..classes = ['instances'] |
300 ..text = '0', | 300 ..text = '0', |
301 new SpanElement()..classes = const ['bytes'] | 301 new SpanElement()..classes = ['bytes'] |
302 ..text = '0B', | 302 ..text = '0B', |
303 new SpanElement()..classes = const ['instances'] | 303 new SpanElement()..classes = ['instances'] |
304 ..text = '0', | 304 ..text = '0', |
305 new SpanElement()..classes = const ['bytes'] | 305 new SpanElement()..classes = ['bytes'] |
306 ..text = '0B', | 306 ..text = '0B', |
307 new SpanElement()..classes = const ['instances'] | 307 new SpanElement()..classes = ['instances'] |
308 ..text = '0', | 308 ..text = '0', |
309 new SpanElement()..classes = const ['bytes'] | 309 new SpanElement()..classes = ['bytes'] |
310 ..text = '0B', | 310 ..text = '0B', |
311 new SpanElement()..classes = const ['instances'] | 311 new SpanElement()..classes = ['instances'] |
312 ..text = '0', | 312 ..text = '0', |
313 new SpanElement()..classes = const ['name'] | 313 new SpanElement()..classes = ['name'] |
314 ]; | 314 ]; |
315 | 315 |
316 Element _createCollectionHeader() => | 316 Element _createCollectionHeader() => |
317 new DivElement() | 317 new DivElement() |
318 ..children = [ | 318 ..children = [ |
319 new DivElement() | 319 new DivElement() |
320 ..classes = const ['collection-item'] | 320 ..classes = ['collection-item'] |
321 ..children = [ | 321 ..children = [ |
322 new SpanElement()..classes = const ['group'] | 322 new SpanElement()..classes = ['group'] |
323 ..text = 'Accumulated', | 323 ..text = 'Accumulated', |
324 new SpanElement()..classes = const ['group'] | 324 new SpanElement()..classes = ['group'] |
325 ..text = 'Current', | 325 ..text = 'Current', |
326 new SpanElement()..classes = const ['group'] | 326 new SpanElement()..classes = ['group'] |
327 ..text = '(NEW) Accumulated', | 327 ..text = '(NEW) Accumulated', |
328 new SpanElement()..classes = const ['group'] | 328 new SpanElement()..classes = ['group'] |
329 ..text = '(NEW) Current', | 329 ..text = '(NEW) Current', |
330 new SpanElement()..classes = const ['group'] | 330 new SpanElement()..classes = ['group'] |
331 ..text = '(OLD) Accumulated', | 331 ..text = '(OLD) Accumulated', |
332 new SpanElement()..classes = const ['group'] | 332 new SpanElement()..classes = ['group'] |
333 ..text = '(OLD) Current', | 333 ..text = '(OLD) Current', |
334 ], | 334 ], |
335 new DivElement() | 335 new DivElement() |
336 ..classes = const ['collection-item'] | 336 ..classes = ['collection-item'] |
337 ..children = [ | 337 ..children = [ |
338 _createHeaderButton(const ['bytes'], 'Size', | 338 _createHeaderButton(const ['bytes'], 'Size', |
339 _SortingField.accumulatedSize, | 339 _SortingField.accumulatedSize, |
340 _SortingDirection.descending), | 340 _SortingDirection.descending), |
341 _createHeaderButton(const ['instances'], 'Instances', | 341 _createHeaderButton(const ['instances'], 'Instances', |
342 _SortingField.accumulatedInstances, | 342 _SortingField.accumulatedInstances, |
343 _SortingDirection.descending), | 343 _SortingDirection.descending), |
344 _createHeaderButton(const ['bytes'], 'Size', | 344 _createHeaderButton(const ['bytes'], 'Size', |
345 _SortingField.currentSize, | 345 _SortingField.currentSize, |
346 _SortingDirection.descending), | 346 _SortingDirection.descending), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 final collections = '${space.collections}'; | 432 final collections = '${space.collections}'; |
433 final avgCollectionTime = | 433 final avgCollectionTime = |
434 '${Utils.formatDurationInMilliseconds(space.avgCollectionTime)} ms'; | 434 '${Utils.formatDurationInMilliseconds(space.avgCollectionTime)} ms'; |
435 final totalCollectionTime = | 435 final totalCollectionTime = |
436 '${Utils.formatDurationInSeconds(space.totalCollectionTime)} secs'; | 436 '${Utils.formatDurationInSeconds(space.totalCollectionTime)} secs'; |
437 final avgCollectionPeriod = | 437 final avgCollectionPeriod = |
438 '${Utils.formatDurationInMilliseconds(space.avgCollectionPeriod)} ms'; | 438 '${Utils.formatDurationInMilliseconds(space.avgCollectionPeriod)} ms'; |
439 return [ | 439 return [ |
440 new DivElement()..classes = ['memberItem'] | 440 new DivElement()..classes = ['memberItem'] |
441 ..children = [ | 441 ..children = [ |
442 new DivElement()..classes = ['memberName']..text = 'used', | 442 new DivElement()..classes = ['memberName'] |
| 443 ..text = 'used', |
443 new DivElement()..classes = ['memberValue'] | 444 new DivElement()..classes = ['memberValue'] |
444 ..text = used | 445 ..text = used |
445 ], | 446 ], |
446 new DivElement()..classes = ['memberItem'] | 447 new DivElement()..classes = ['memberItem'] |
447 ..children = [ | 448 ..children = [ |
448 new DivElement()..classes = ['memberName'] | 449 new DivElement()..classes = ['memberName'] |
449 ..text = 'external', | 450 ..text = 'external', |
450 new DivElement()..classes = ['memberValue'] | 451 new DivElement()..classes = ['memberValue'] |
451 ..text = ext | 452 ..text = ext |
452 ], | 453 ], |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 s.newSpace.current.instances; | 575 s.newSpace.current.instances; |
575 static int _getOldAccumulatedSize(M.ClassHeapStats s) => | 576 static int _getOldAccumulatedSize(M.ClassHeapStats s) => |
576 s.oldSpace.accumulated.bytes; | 577 s.oldSpace.accumulated.bytes; |
577 static int _getOldAccumulatedInstances(M.ClassHeapStats s) => | 578 static int _getOldAccumulatedInstances(M.ClassHeapStats s) => |
578 s.oldSpace.accumulated.instances; | 579 s.oldSpace.accumulated.instances; |
579 static int _getOldCurrentSize(M.ClassHeapStats s) => | 580 static int _getOldCurrentSize(M.ClassHeapStats s) => |
580 s.oldSpace.current.bytes; | 581 s.oldSpace.current.bytes; |
581 static int _getOldCurrentInstances(M.ClassHeapStats s) => | 582 static int _getOldCurrentInstances(M.ClassHeapStats s) => |
582 s.oldSpace.current.instances; | 583 s.oldSpace.current.instances; |
583 } | 584 } |
OLD | NEW |