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

Side by Side Diff: runtime/observatory/lib/src/repositories/sample_profile.dart

Issue 2773073003: Revert "Added page to Observatory to display native memory allocation information." (Closed)
Patch Set: 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
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 part of repositories; 5 part of repositories;
6 6
7 String _tagToString(M.SampleProfileTag tag) { 7 String _tagToString(M.SampleProfileTag tag) {
8 switch (tag) { 8 switch (tag) {
9 case M.SampleProfileTag.userVM: 9 case M.SampleProfileTag.userVM:
10 return 'UserVM'; 10 return 'UserVM';
(...skipping 14 matching lines...) Expand all
25 final SampleProfileLoadingProgress progress; 25 final SampleProfileLoadingProgress progress;
26 SampleProfileLoadingProgressEvent(this.progress); 26 SampleProfileLoadingProgressEvent(this.progress);
27 } 27 }
28 28
29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress { 29 class SampleProfileLoadingProgress extends M.SampleProfileLoadingProgress {
30 StreamController<SampleProfileLoadingProgressEvent> _onProgress = 30 StreamController<SampleProfileLoadingProgressEvent> _onProgress =
31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast(); 31 new StreamController<SampleProfileLoadingProgressEvent>.broadcast();
32 Stream<SampleProfileLoadingProgressEvent> get onProgress => 32 Stream<SampleProfileLoadingProgressEvent> get onProgress =>
33 _onProgress.stream; 33 _onProgress.stream;
34 34
35 final ServiceObjectOwner owner; 35 final S.Isolate isolate;
36 final S.Class cls; 36 final S.Class cls;
37 final M.SampleProfileTag tag; 37 final M.SampleProfileTag tag;
38 final bool clear; 38 final bool clear;
39 final M.SampleProfileType type;
40 39
41 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching; 40 M.SampleProfileLoadingStatus _status = M.SampleProfileLoadingStatus.fetching;
42 double _progress = 0.0; 41 double _progress = 0.0;
43 final Stopwatch _fetchingTime = new Stopwatch(); 42 final Stopwatch _fetchingTime = new Stopwatch();
44 final Stopwatch _loadingTime = new Stopwatch(); 43 final Stopwatch _loadingTime = new Stopwatch();
45 CpuProfile _profile; 44 CpuProfile _profile;
46 45
47 M.SampleProfileLoadingStatus get status => _status; 46 M.SampleProfileLoadingStatus get status => _status;
48 double get progress => _progress; 47 double get progress => _progress;
49 Duration get fetchingTime => _fetchingTime.elapsed; 48 Duration get fetchingTime => _fetchingTime.elapsed;
50 Duration get loadingTime => _loadingTime.elapsed; 49 Duration get loadingTime => _loadingTime.elapsed;
51 CpuProfile get profile => _profile; 50 CpuProfile get profile => _profile;
52 51
53 SampleProfileLoadingProgress(this.owner, this.tag, this.clear, 52 SampleProfileLoadingProgress(this.isolate, this.tag, this.clear, {this.cls}) {
54 {this.type: M.SampleProfileType.cpu, this.cls}) {
55 _run(); 53 _run();
56 } 54 }
57 55
58 Future _run() async { 56 Future _run() async {
59 _fetchingTime.start(); 57 _fetchingTime.start();
60 try { 58 try {
61 if (clear && (type == M.SampleProfileType.cpu)) { 59 if (clear) {
62 await owner.invokeRpc('_clearCpuProfile', {}); 60 await isolate.invokeRpc('_clearCpuProfile', {});
63 } 61 }
64 62
65 var response; 63 final response = cls != null
66 if (type == M.SampleProfileType.cpu) { 64 ? await cls.getAllocationSamples(_tagToString(tag))
67 response = cls != null 65 : await isolate
68 ? await cls.getAllocationSamples(_tagToString(tag)) 66 .invokeRpc('_getCpuProfile', {'tags': _tagToString(tag)});
69 : await owner
70 .invokeRpc('_getCpuProfile', {'tags': _tagToString(tag)});
71 } else if (type == M.SampleProfileType.memory) {
72 assert(owner is M.VM);
73 M.VM vm = owner as M.VM;
74 response = await owner.invokeRpc(
75 '_getNativeAllocationSamples', {'tags': _tagToString(tag)});
76 } else {
77 throw new Exception('Unknown M.SampleProfileType: $type');
78 }
79 67
80 _fetchingTime.stop(); 68 _fetchingTime.stop();
81 _loadingTime.start(); 69 _loadingTime.start();
82 _status = M.SampleProfileLoadingStatus.loading; 70 _status = M.SampleProfileLoadingStatus.loading;
83 _triggerOnProgress(); 71 _triggerOnProgress();
84 72
85 CpuProfile profile = new CpuProfile(); 73 CpuProfile profile = new CpuProfile();
86 74
87 Stream<double> progress = profile.loadProgress(owner, response); 75 Stream<double> progress = profile.loadProgress(isolate, response);
88 progress.listen((value) { 76 progress.listen((value) {
89 _progress = value; 77 _progress = value;
90 _triggerOnProgress(); 78 _triggerOnProgress();
91 }); 79 });
92 80
93 await progress.drain(); 81 await progress.drain();
94 82
95 profile.buildFunctionCallerAndCallees(); 83 profile.buildFunctionCallerAndCallees();
96 _profile = profile; 84 _profile = profile;
97 85
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 implements M.IsolateSampleProfileRepository { 117 implements M.IsolateSampleProfileRepository {
130 SampleProfileLoadingProgress _last; 118 SampleProfileLoadingProgress _last;
131 119
132 Stream<SampleProfileLoadingProgressEvent> get( 120 Stream<SampleProfileLoadingProgressEvent> get(
133 M.IsolateRef i, M.SampleProfileTag t, 121 M.IsolateRef i, M.SampleProfileTag t,
134 {bool clear: false, bool forceFetch: false}) { 122 {bool clear: false, bool forceFetch: false}) {
135 assert(clear != null); 123 assert(clear != null);
136 assert(forceFetch != null); 124 assert(forceFetch != null);
137 S.Isolate isolate = i as S.Isolate; 125 S.Isolate isolate = i as S.Isolate;
138 assert(isolate != null); 126 assert(isolate != null);
139 if ((_last != null) && !clear && !forceFetch && (_last.owner == isolate)) { 127 if (_last != null && !clear && !forceFetch && _last.isolate == isolate) {
140 _last.reuse(); 128 _last.reuse();
141 } else { 129 } else {
142 _last = new SampleProfileLoadingProgress(isolate, t, clear); 130 _last = new SampleProfileLoadingProgress(isolate, t, clear);
143 } 131 }
144 return _last.onProgress; 132 return _last.onProgress;
145 } 133 }
146 } 134 }
147 135
148 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository { 136 class ClassSampleProfileRepository implements M.ClassSampleProfileRepository {
149 Stream<SampleProfileLoadingProgressEvent> get( 137 Stream<SampleProfileLoadingProgressEvent> get(
(...skipping 11 matching lines...) Expand all
161 assert(cls != null); 149 assert(cls != null);
162 return cls.setTraceAllocations(true); 150 return cls.setTraceAllocations(true);
163 } 151 }
164 152
165 Future disable(M.IsolateRef i, M.ClassRef c) { 153 Future disable(M.IsolateRef i, M.ClassRef c) {
166 S.Class cls = c as S.Class; 154 S.Class cls = c as S.Class;
167 assert(cls != null); 155 assert(cls != null);
168 return cls.setTraceAllocations(false); 156 return cls.setTraceAllocations(false);
169 } 157 }
170 } 158 }
171
172 class NativeMemorySampleProfileRepository
173 implements M.NativeMemorySampleProfileRepository {
174 SampleProfileLoadingProgress _last;
175
176 Stream<SampleProfileLoadingProgressEvent> get(M.VM vm, M.SampleProfileTag t,
177 {bool forceFetch: false}) {
178 assert(forceFetch != null);
179 if ((_last != null) && !forceFetch) {
180 _last.reuse();
181 } else {
182 _last = new SampleProfileLoadingProgress(vm, t, false,
183 type: M.SampleProfileType.memory);
184 }
185 return _last.onProgress;
186 }
187 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/models/repositories/sample_profile.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698