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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/elements/heap_profile.dart

Issue 184233007: Refactor Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
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 library heap_profile_element; 5 library heap_profile_element;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'isolate_element.dart';
8 import 'package:logging/logging.dart'; 9 import 'package:logging/logging.dart';
9 import 'package:polymer/polymer.dart'; 10 import 'package:polymer/polymer.dart';
10 import 'observatory_element.dart'; 11 import 'package:observatory/app.dart';
11 12
12 /// Displays an Error response. 13 /// Displays an Error response.
13 @CustomTag('heap-profile') 14 @CustomTag('heap-profile')
14 class HeapProfileElement extends ObservatoryElement { 15 class HeapProfileElement extends IsolateElement {
15 // Indexes into VM provided map. 16 // Indexes into VM provided map.
16 static const ALLOCATED_BEFORE_GC = 0; 17 static const ALLOCATED_BEFORE_GC = 0;
17 static const ALLOCATED_BEFORE_GC_SIZE = 1; 18 static const ALLOCATED_BEFORE_GC_SIZE = 1;
18 static const LIVE_AFTER_GC = 2; 19 static const LIVE_AFTER_GC = 2;
19 static const LIVE_AFTER_GC_SIZE = 3; 20 static const LIVE_AFTER_GC_SIZE = 3;
20 static const ALLOCATED_SINCE_GC = 4; 21 static const ALLOCATED_SINCE_GC = 4;
21 static const ALLOCATED_SINCE_GC_SIZE = 5; 22 static const ALLOCATED_SINCE_GC_SIZE = 5;
22 static const ACCUMULATED = 6; 23 static const ACCUMULATED = 6;
23 static const ACCUMULATED_SIZE = 7; 24 static const ACCUMULATED_SIZE = 7;
24 25
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 assert(_fullDataTable != null); 99 assert(_fullDataTable != null);
99 assert(_combinedDataTable != null); 100 assert(_combinedDataTable != null);
100 _fullDataTable.clearRows(); 101 _fullDataTable.clearRows();
101 _combinedDataTable.clearRows(); 102 _combinedDataTable.clearRows();
102 for (Map cls in profile['members']) { 103 for (Map cls in profile['members']) {
103 if (_classHasNoAllocations(cls)) { 104 if (_classHasNoAllocations(cls)) {
104 // If a class has no allocations, don't display it. 105 // If a class has no allocations, don't display it.
105 continue; 106 continue;
106 } 107 }
107 var vm_name = cls['class']['name']; 108 var vm_name = cls['class']['name'];
108 var url = 109 var url = isolate.relativeLink(cls['class']['id']);
109 app.locationManager.currentIsolateRelativeLink(cls['class']['id']);
110 _fullDataTable.addRow([ 110 _fullDataTable.addRow([
111 '<a title="$vm_name" href="$url">' 111 '<a title="$vm_name" href="$url">'
112 '${_fullTableColumnValue(cls, 0)}</a>', 112 '${_fullTableColumnValue(cls, 0)}</a>',
113 _fullTableColumnValue(cls, 1), 113 _fullTableColumnValue(cls, 1),
114 _fullTableColumnValue(cls, 2), 114 _fullTableColumnValue(cls, 2),
115 _fullTableColumnValue(cls, 3), 115 _fullTableColumnValue(cls, 3),
116 _fullTableColumnValue(cls, 4), 116 _fullTableColumnValue(cls, 4),
117 _fullTableColumnValue(cls, 5), 117 _fullTableColumnValue(cls, 5),
118 _fullTableColumnValue(cls, 6), 118 _fullTableColumnValue(cls, 6),
119 _fullTableColumnValue(cls, 7), 119 _fullTableColumnValue(cls, 7),
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 case 5: 216 case 5:
217 return v['new'][ALLOCATED_BEFORE_GC_SIZE] + 217 return v['new'][ALLOCATED_BEFORE_GC_SIZE] +
218 v['old'][ALLOCATED_BEFORE_GC_SIZE]; 218 v['old'][ALLOCATED_BEFORE_GC_SIZE];
219 case 6: 219 case 6:
220 return v['new'][LIVE_AFTER_GC_SIZE] + v['old'][LIVE_AFTER_GC_SIZE]; 220 return v['new'][LIVE_AFTER_GC_SIZE] + v['old'][LIVE_AFTER_GC_SIZE];
221 } 221 }
222 throw new FallThroughError(); 222 throw new FallThroughError();
223 } 223 }
224 224
225 void refresh(var done) { 225 void refresh(var done) {
226 var isolateId = app.locationManager.currentIsolateId(); 226 isolate.getMap('/allocationprofile').then((Map response) {
227 var isolate = app.isolateManager.getIsolate(isolateId);
228 if (isolate == null) {
229 Logger.root.info('No isolate found.');
230 return;
231 }
232 var request = '/$isolateId/allocationprofile';
233 app.requestManager.requestMap(request).then((Map response) {
234 assert(response['type'] == 'AllocationProfile'); 227 assert(response['type'] == 'AllocationProfile');
235 profile = response; 228 profile = response;
236 }).catchError((e, st) { 229 }).catchError((e, st) {
237 Logger.root.info('$e $st'); 230 Logger.root.info('$e $st');
238 }).whenComplete(done); 231 }).whenComplete(done);
239 } 232 }
240 233
241 void resetAccumulator(Event e, var detail, Node target) { 234 void resetAccumulator(Event e, var detail, Node target) {
242 var isolateId = app.locationManager.currentIsolateId(); 235 isolate.getMap('/allocationprofile/reset').then((Map response) {
243 var isolate = app.isolateManager.getIsolate(isolateId);
244 if (isolate == null) {
245 Logger.root.info('No isolate found.');
246 return;
247 }
248 var request = '/$isolateId/allocationprofile/reset';
249 app.requestManager.requestMap(request).then((Map response) {
250 assert(response['type'] == 'AllocationProfile'); 236 assert(response['type'] == 'AllocationProfile');
251 profile = response; 237 profile = response;
252 }).catchError((e, st) { 238 }).catchError((e, st) {
253 Logger.root.info('$e $st'); 239 Logger.root.info('$e $st');
254 }); 240 });
255 } 241 }
256 242
257 void profileChanged(oldValue) { 243 void profileChanged(oldValue) {
258 _updateChartData(); 244 _updateChartData();
259 notifyPropertyChange(#formattedAverage, [], formattedAverage); 245 notifyPropertyChange(#formattedAverage, [], formattedAverage);
(...skipping 23 matching lines...) Expand all
283 269
284 @observable String formattedTotalCollectionTime(bool newSpace) { 270 @observable String formattedTotalCollectionTime(bool newSpace) {
285 if (profile == null) { 271 if (profile == null) {
286 return ''; 272 return '';
287 } 273 }
288 String space = newSpace ? 'new' : 'old'; 274 String space = newSpace ? 'new' : 'old';
289 Map heap = profile['heaps'][space]; 275 Map heap = profile['heaps'][space];
290 return '${ObservatoryApplication.timeUnits(heap['time'])} secs'; 276 return '${ObservatoryApplication.timeUnits(heap['time'])} secs';
291 } 277 }
292 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698