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

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

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Added page to Observatory to display native memory allocation information. Created 3 years, 9 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
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 library native_memory_profile;
6
7 import 'dart:async';
8 import 'dart:html';
9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart';
11 import 'package:observatory/src/elements/helpers/nav_bar.dart';
12 import 'package:observatory/src/elements/helpers/nav_menu.dart';
13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
14 import 'package:observatory/src/elements/helpers/tag.dart';
15 import 'package:observatory/src/elements/helpers/uris.dart';
16 import 'package:observatory/src/elements/nav/notify.dart';
17 import 'package:observatory/src/elements/nav/refresh.dart';
18 import 'package:observatory/src/elements/nav/top_menu.dart';
19 import 'package:observatory/src/elements/nav/vm_menu.dart';
20 import 'package:observatory/src/elements/sample_buffer_control.dart';
21 import 'package:observatory/src/elements/stack_trace_tree_config.dart';
22
23 class NativeMemoryProfileElement extends HtmlElement implements Renderable {
24 static const tag =
25 const Tag<NativeMemoryProfileElement>('native-memory-profile', dependencie s: const [
26 NavTopMenuElement.tag,
27 NavVMMenuElement.tag,
28 NavRefreshElement.tag,
29 NavNotifyElement.tag,
30 SampleBufferControlElement.tag,
31 StackTraceTreeConfigElement.tag,
32 CpuProfileVirtualTreeElement.tag,
33 ]);
34
35 RenderingScheduler<NativeMemoryProfileElement> _r;
36
37 Stream<RenderedEvent<NativeMemoryProfileElement>> get onRendered => _r.onRende red;
Cutch 2017/03/21 20:27:10 long line.
bkonyi 2017/03/22 21:25:21 Done.
38
39 M.VM _vm;
40 M.EventRepository _events;
41 M.NotificationRepository _notifications;
42 M.NativeMemorySampleProfileRepository _profiles;
43 Stream<M.SampleProfileLoadingProgressEvent> _progressStream;
44 M.SampleProfileLoadingProgress _progress;
45 M.SampleProfileTag _tag = M.SampleProfileTag.none;
46 ProfileTreeMode _mode = ProfileTreeMode.function;
47 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive;
48 String _filter = '';
49
50 M.NotificationRepository get notifications => _notifications;
51 M.NativeMemorySampleProfileRepository get profiles => _profiles;
52 //with non-isolate version
Cutch 2017/03/21 20:27:11 space between // and text.
bkonyi 2017/03/22 21:25:21 Done.
53 M.VMRef get vm => _vm;
54
55 factory NativeMemoryProfileElement(
56 M.VM vm,
57 M.EventRepository events,
58 M.NotificationRepository notifications,
59 M.NativeMemorySampleProfileRepository profiles,
60 {RenderingQueue queue}) {
61 assert(vm != null);
62 assert(events != null);
63 assert(notifications != null);
64 assert(profiles != null);
65 NativeMemoryProfileElement e = document.createElement(tag.name);
66 e._r = new RenderingScheduler(e, queue: queue);
67 e._vm = vm;
68 e._events = events;
69 e._notifications = notifications;
70 e._profiles = profiles;
71 return e;
72 }
73
74 NativeMemoryProfileElement.created() : super.created();
75
76 @override
77 attached() {
78 super.attached();
79 _r.enable();
80 _request();
81 }
82
83 @override
84 detached() {
85 super.detached();
86 _r.disable(notify: true);
87 children = [];
88 }
89
90 void render() {
91 var content = [
92 navBar([
93 new NavTopMenuElement(queue: _r.queue),
94 new NavVMMenuElement(_vm, _events, queue: _r.queue),
95 navMenu('native memory profile', link: Uris.nativeMemory()),
96 new NavRefreshElement(queue: _r.queue)..onRefresh.listen(_refresh),
97 new NavNotifyElement(_notifications, queue: _r.queue)
98 ]),
99 ];
100 if (_progress == null) {
101 children = content;
102 return;
103 }
104 content.add(new SampleBufferControlElement(_progress, _progressStream,
105 selectedTag: _tag, queue: _r.queue)
106 ..onTagChange.listen((e) {
107 _tag = e.element.selectedTag;
108 _request();
109 }));
110 if (_progress.status == M.SampleProfileLoadingStatus.loaded) {
111 CpuProfileVirtualTreeElement tree;
112 content.addAll([
113 new BRElement(),
114 new StackTraceTreeConfigElement(
115 mode: _mode,
116 direction: _direction,
117 filter: _filter,
118 queue: _r.queue)
119 ..onModeChange.listen((e) {
120 _mode = tree.mode = e.element.mode;
121 })
122 ..onFilterChange.listen((e) {
123 _filter = e.element.filter.trim();
124 tree.filters = _filter.isNotEmpty
125 ? [
126 (node) {
127 return node.name.contains(_filter);
128 }
129 ]
130 : const [];
131 })
132 ..onDirectionChange.listen((e) {
133 _direction = tree.direction = e.element.direction;
134 }),
135 new BRElement(),
136 tree = new CpuProfileVirtualTreeElement(_vm, _progress.profile,
137 queue: _r.queue, type: ProfileTreeType.memory)
138 ]);
139 }
140 children = content;
141 }
142
143 Future _request({bool forceFetch: false}) async {
144 _progress = null;
145 _progressStream =
146 _profiles.get(_vm, _tag, forceFetch: forceFetch);
147 _r.dirty();
148 _progress = (await _progressStream.first).progress;
149 _r.dirty();
150 if (M.isSampleProcessRunning(_progress.status)) {
151 _progress = (await _progressStream.last).progress;
152 _r.dirty();
153 }
154 }
155
156 Future _refresh(e) async {
157 e.element.disabled = true;
158 await _request(forceFetch: true);
159 e.element.disabled = false;
160 }
161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698