Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: runtime/observatory/lib/src/elements/memory/allocations.dart

Issue 3002843002: Introduce heap snapshot into Memory Dashboard (Closed)
Patch Set: Address CL comments Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// This Element is part of MemoryDashboardElement. 5 /// This Element is part of MemoryDashboardElement.
6 /// 6 ///
7 /// The Element is stripped down version of AllocationProfileElement where 7 /// The Element is stripped down version of AllocationProfileElement where
8 /// concepts like old and new space has been hidden away. 8 /// concepts like old and new space has been hidden away.
9 /// 9 ///
10 /// For each class in the system it is shown the Total number of instances 10 /// For each class in the system it is shown the Total number of instances
(...skipping 14 matching lines...) Expand all
25 enum _SortingField { 25 enum _SortingField {
26 accumulatedSize, 26 accumulatedSize,
27 accumulatedInstances, 27 accumulatedInstances,
28 currentSize, 28 currentSize,
29 currentInstances, 29 currentInstances,
30 className, 30 className,
31 } 31 }
32 32
33 enum _SortingDirection { ascending, descending } 33 enum _SortingDirection { ascending, descending }
34 34
35 class MemoryProfileElement extends HtmlElement implements Renderable { 35 class MemoryAllocationsElement extends HtmlElement implements Renderable {
36 static const tag = const Tag<MemoryProfileElement>('memory-profile', 36 static const tag = const Tag<MemoryAllocationsElement>('memory-allocations',
37 dependencies: const [ClassRefElement.tag, VirtualCollectionElement.tag]); 37 dependencies: const [ClassRefElement.tag, VirtualCollectionElement.tag]);
38 38
39 RenderingScheduler<MemoryProfileElement> _r; 39 RenderingScheduler<MemoryAllocationsElement> _r;
40 40
41 Stream<RenderedEvent<MemoryProfileElement>> get onRendered => _r.onRendered; 41 Stream<RenderedEvent<MemoryAllocationsElement>> get onRendered =>
42 _r.onRendered;
42 43
43 M.IsolateRef _isolate; 44 M.IsolateRef _isolate;
44 M.EventRepository _events; 45 M.EventRepository _events;
45 M.AllocationProfileRepository _repository; 46 M.AllocationProfileRepository _repository;
46 M.AllocationProfile _profile; 47 M.AllocationProfile _profile;
47 M.EditorRepository _editor; 48 M.EditorRepository _editor;
48 StreamSubscription _gcSubscription; 49 StreamSubscription _gcSubscription;
49 _SortingField _sortingField = _SortingField.accumulatedInstances; 50 _SortingField _sortingField = _SortingField.accumulatedInstances;
50 _SortingDirection _sortingDirection = _SortingDirection.descending; 51 _SortingDirection _sortingDirection = _SortingDirection.descending;
51 52
52 M.IsolateRef get isolate => _isolate; 53 M.IsolateRef get isolate => _isolate;
53 54
54 factory MemoryProfileElement(M.IsolateRef isolate, M.EditorRepository editor, 55 factory MemoryAllocationsElement(
55 M.EventRepository events, M.AllocationProfileRepository repository, 56 M.IsolateRef isolate,
57 M.EditorRepository editor,
58 M.EventRepository events,
59 M.AllocationProfileRepository repository,
56 {RenderingQueue queue}) { 60 {RenderingQueue queue}) {
57 assert(isolate != null); 61 assert(isolate != null);
58 assert(events != null); 62 assert(events != null);
59 assert(editor != null); 63 assert(editor != null);
60 assert(repository != null); 64 assert(repository != null);
61 MemoryProfileElement e = document.createElement(tag.name); 65 MemoryAllocationsElement e = document.createElement(tag.name);
62 e._r = new RenderingScheduler(e, queue: queue); 66 e._r = new RenderingScheduler(e, queue: queue);
63 e._isolate = isolate; 67 e._isolate = isolate;
64 e._editor = editor; 68 e._editor = editor;
65 e._events = events; 69 e._events = events;
66 e._repository = repository; 70 e._repository = repository;
67 return e; 71 return e;
68 } 72 }
69 73
70 MemoryProfileElement.created() : super.created(); 74 MemoryAllocationsElement.created() : super.created();
71 75
72 @override 76 @override
73 attached() { 77 attached() {
74 super.attached(); 78 super.attached();
75 _r.enable(); 79 _r.enable();
76 _refresh(); 80 _refresh();
77 _gcSubscription = _events.onGCEvent.listen((e) { 81 _gcSubscription = _events.onGCEvent.listen((e) {
78 if (e.isolate.id == _isolate.id) { 82 if (e.isolate.id == _isolate.id) {
79 _refresh(); 83 _refresh();
80 } 84 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 229 }
226 230
227 void _updateCollectionLine(Element e, M.ClassHeapStats item, index) { 231 void _updateCollectionLine(Element e, M.ClassHeapStats item, index) {
228 e.children[0].text = Utils.formatSize(_getAccumulatedSize(item)); 232 e.children[0].text = Utils.formatSize(_getAccumulatedSize(item));
229 e.children[1].text = '${_getAccumulatedInstances(item)}'; 233 e.children[1].text = '${_getAccumulatedInstances(item)}';
230 e.children[2].text = Utils.formatSize(_getCurrentSize(item)); 234 e.children[2].text = Utils.formatSize(_getCurrentSize(item));
231 e.children[3].text = '${_getCurrentInstances(item)}'; 235 e.children[3].text = '${_getCurrentInstances(item)}';
232 e.children[4] = new ClassRefElement(_isolate, item.clazz, queue: _r.queue) 236 e.children[4] = new ClassRefElement(_isolate, item.clazz, queue: _r.queue)
233 ..classes = ['name']; 237 ..classes = ['name'];
234 Element.clickEvent.forTarget(e.children[4], useCapture: true).listen((e) { 238 Element.clickEvent.forTarget(e.children[4], useCapture: true).listen((e) {
235 if (_editor.canOpenClass) { 239 if (_editor.isAvailable) {
236 e.preventDefault(); 240 e.preventDefault();
237 _editor.openClass(isolate, item.clazz); 241 _editor.openClass(isolate, item.clazz);
238 } 242 }
239 }); 243 });
240 } 244 }
241 245
242 Future _refresh({bool gc: false, bool reset: false}) async { 246 Future _refresh({bool gc: false, bool reset: false}) async {
243 _profile = null; 247 _profile = null;
244 _r.dirty(); 248 _r.dirty();
245 _profile = await _repository.get(_isolate, gc: gc, reset: reset); 249 _profile = await _repository.get(_isolate, gc: gc, reset: reset);
246 _r.dirty(); 250 _r.dirty();
247 } 251 }
248 252
249 static int _getAccumulatedSize(M.ClassHeapStats s) => 253 static int _getAccumulatedSize(M.ClassHeapStats s) =>
250 s.newSpace.accumulated.bytes + s.oldSpace.accumulated.bytes; 254 s.newSpace.accumulated.bytes + s.oldSpace.accumulated.bytes;
251 static int _getAccumulatedInstances(M.ClassHeapStats s) => 255 static int _getAccumulatedInstances(M.ClassHeapStats s) =>
252 s.newSpace.accumulated.instances + s.oldSpace.accumulated.instances; 256 s.newSpace.accumulated.instances + s.oldSpace.accumulated.instances;
253 static int _getCurrentSize(M.ClassHeapStats s) => 257 static int _getCurrentSize(M.ClassHeapStats s) =>
254 s.newSpace.current.bytes + s.oldSpace.current.bytes; 258 s.newSpace.current.bytes + s.oldSpace.current.bytes;
255 static int _getCurrentInstances(M.ClassHeapStats s) => 259 static int _getCurrentInstances(M.ClassHeapStats s) =>
256 s.newSpace.current.instances + s.oldSpace.current.instances; 260 s.newSpace.current.instances + s.oldSpace.current.instances;
257 } 261 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/css/shared.css ('k') | runtime/observatory/lib/src/elements/memory/dashboard.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698