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

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

Issue 2204563003: Converted Observatory cpu-profile element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Added lifecycle tests Created 4 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) 2013, the Dart project authors. Please see the AUTHORS file 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 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 class_view_element; 5 library class_view_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'observatory_element.dart'; 8 import 'observatory_element.dart';
9 import 'package:observatory/cpu_profile.dart'; 9 import 'sample_buffer_control.dart';
10 import 'stack_trace_tree_config.dart';
11 import 'cpu_profile/virtual_tree.dart';
10 import 'package:observatory/elements.dart'; 12 import 'package:observatory/elements.dart';
13 import 'package:observatory/models.dart' as M;
11 import 'package:observatory/service.dart'; 14 import 'package:observatory/service.dart';
15 import 'package:observatory/repositories.dart';
12 import 'package:polymer/polymer.dart'; 16 import 'package:polymer/polymer.dart';
13 17
14 @CustomTag('class-view') 18 @CustomTag('class-view')
15 class ClassViewElement extends ObservatoryElement { 19 class ClassViewElement extends ObservatoryElement {
16 @published Class cls; 20 @published Class cls;
17 @observable ServiceMap instances; 21 @observable ServiceMap instances;
18 @observable int reachableBytes; 22 @observable int reachableBytes;
19 @observable int retainedBytes; 23 @observable int retainedBytes;
20 @observable ObservableList mostRetained; 24 @observable ObservableList mostRetained;
21 SampleBufferControlElement sampleBufferControlElement; 25 SampleBufferControlElement sampleBufferControlElement;
22 StackTraceTreeConfigElement stackTraceTreeConfigElement; 26 StackTraceTreeConfigElement stackTraceTreeConfigElement;
23 CpuProfileVirtualTreeElement cpuProfileTreeElement; 27 CpuProfileVirtualTreeElement cpuProfileTreeElement;
28 ClassSampleProfileRepository repository = new ClassSampleProfileRepository();
29
24 30
25 ClassViewElement.created() : super.created(); 31 ClassViewElement.created() : super.created();
26 32
27 Future<ServiceObject> evaluate(String expression) { 33 Future<ServiceObject> evaluate(String expression) {
28 return cls.evaluate(expression); 34 return cls.evaluate(expression);
29 } 35 }
30 36
31 Future<ServiceObject> reachable(var limit) { 37 Future<ServiceObject> reachable(var limit) {
32 return cls.isolate.getInstances(cls, limit).then((ServiceMap obj) { 38 return cls.isolate.getInstances(cls, limit).then((ServiceMap obj) {
33 instances = obj; 39 instances = obj;
(...skipping 18 matching lines...) Expand all
52 } 58 }
53 59
54 Future<ServiceObject> retainedSize(var dummy) { 60 Future<ServiceObject> retainedSize(var dummy) {
55 return cls.isolate.getRetainedSize(cls).then((Instance obj) { 61 return cls.isolate.getRetainedSize(cls).then((Instance obj) {
56 retainedBytes = int.parse(obj.valueAsString); 62 retainedBytes = int.parse(obj.valueAsString);
57 }); 63 });
58 } 64 }
59 65
60 void attached() { 66 void attached() {
61 super.attached(); 67 super.attached();
62 sampleBufferControlElement =
63 shadowRoot.querySelector('#sampleBufferControl');
64 assert(sampleBufferControlElement != null);
65 sampleBufferControlElement.onSampleBufferUpdate = onSampleBufferChange;
66 sampleBufferControlElement.state =
67 SampleBufferControlElement.kNotLoadedState;
68 stackTraceTreeConfigElement =
69 shadowRoot.querySelector('#stackTraceTreeConfig');
70 assert(stackTraceTreeConfigElement != null);
71 stackTraceTreeConfigElement.onTreeConfigChange = onTreeConfigChange;
72 stackTraceTreeConfigElement.show = false;
73 stackTraceTreeConfigElement.showFilter = false;
74 cpuProfileTreeElement = shadowRoot.querySelector('#cpuProfileTree');
75 assert(cpuProfileTreeElement != null);
76 cpuProfileTreeElement.profile = sampleBufferControlElement.profile;
77 cpuProfileTreeElement.show = false;
78 cls.fields.forEach((field) => field.reload()); 68 cls.fields.forEach((field) => field.reload());
79 sampleBufferControlElement.allocationProfileClass = cls;
80 } 69 }
81 70
82 Future refresh() { 71 Future refresh() async {
83 instances = null; 72 instances = null;
84 retainedBytes = null; 73 retainedBytes = null;
85 mostRetained = null; 74 mostRetained = null;
86 var loads = []; 75 var loads = [];
87 loads.add(cls.reload()); 76 loads.add(await cls.reload());
rmacnak 2016/08/09 20:51:06 List constructed but not used.
cbernaschina 2016/08/09 21:16:54 Done.
88 cls.fields.forEach((field) => loads.add(field.reload()));
89 return Future.wait(loads);
90 } 77 }
91 78
92 onSampleBufferChange(CpuProfile sampleBuffer) { 79 M.SampleProfileTag _tag = M.SampleProfileTag.none;
93 stackTraceTreeConfigElement.show = sampleBuffer.sampleCount > 0;
94 cpuProfileTreeElement.show = sampleBuffer.sampleCount > 0;
95 cpuProfileTreeElement.render();
96 }
97
98 onTreeConfigChange(String modeSelector,
99 String directionSelector,
100 String filter) {
101 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive;
102 if (directionSelector != 'Up') {
103 direction = ProfileTreeDirection.Inclusive;
104 }
105 ProfileTreeMode mode = ProfileTreeMode.Function;
106 if (modeSelector == 'Code') {
107 mode = ProfileTreeMode.Code;
108 }
109 cpuProfileTreeElement.direction = direction;
110 cpuProfileTreeElement.mode = mode;
111 cpuProfileTreeElement.render();
112 }
113 80
114 Future refreshAllocationProfile() async { 81 Future refreshAllocationProfile() async {
115 return sampleBufferControlElement.reload(cls.isolate); 82 shadowRoot.querySelector('#sampleBufferControl').children = const [];
83 shadowRoot.querySelector('#stackTraceTreeConfig').children = const [];
84 shadowRoot.querySelector('#cpuProfileTree').children = const [];
85 final stream = repository.get(cls, _tag);
86 var progress = (await stream.first).progress;
87 shadowRoot.querySelector('#sampleBufferControl')..children = [
88 new SampleBufferControlElement(progress, stream, queue: app.queue,
89 selectedTag: _tag)
90 ..onTagChange.listen((e) {
91 _tag = e.element.selectedTag;
92 refreshAllocationProfile();
93 })
94 ];
95 if (M.isSampleProcessRunning(progress.status)) {
96 progress = await stream.last;
97 }
98 if (progress.status == M.SampleProfileLoadingStatus.loaded) {
99 shadowRoot.querySelector('#stackTraceTreeConfig')..children = [
100 new StackTraceTreeConfigElement(
101 queue: app.queue)
102 ..showFilter = false
103 ..onModeChange.listen((e) {
104 cpuProfileTreeElement.mode = e.element.mode;
105 })
106 ..onDirectionChange.listen((e) {
107 cpuProfileTreeElement.direction = e.element.direction;
108 })
109 ];
110 shadowRoot.querySelector('#cpuProfileTree')..children = [
111 cpuProfileTreeElement = new CpuProfileVirtualTreeElement(cls.isolate,
112 progress.profile, queue: app.queue)
113 ];
114 }
116 } 115 }
117 116
118 Future toggleAllocationTrace() { 117 Future toggleAllocationTrace() {
119 if (cls == null) { 118 if (cls == null) {
120 return new Future(refresh); 119 return new Future(refresh);
121 } 120 }
121 if (cls.traceAllocations) {
122 refreshAllocationProfile();
123 }
122 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh); 124 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh);
123 } 125 }
124 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698