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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/elements/isolate_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) 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 isolate_profile_element; 5 library isolate_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:observatory/observatory.dart'; 10 import 'package:observatory/app.dart';
10 import 'package:polymer/polymer.dart'; 11 import 'package:polymer/polymer.dart';
11 import 'observatory_element.dart';
12 12
13 class ProfileCallerTreeRow extends TableTreeRow { 13 class ProfileCallerTreeRow extends TableTreeRow {
14 final Isolate isolate; 14 final Isolate isolate;
15 @observable final Code code; 15 @observable final Code code;
16 16
17 static String formatPercent(num a, num total) { 17 static String formatPercent(num a, num total) {
18 var percent = 100.0 * (a / total); 18 var percent = 100.0 * (a / total);
19 return '${percent.toStringAsFixed(2)}%'; 19 return '${percent.toStringAsFixed(2)}%';
20 } 20 }
21 21
(...skipping 26 matching lines...) Expand all
48 children.add(row); 48 children.add(row);
49 }); 49 });
50 } 50 }
51 51
52 void onHide() { 52 void onHide() {
53 } 53 }
54 } 54 }
55 55
56 /// Displays an IsolateProfile 56 /// Displays an IsolateProfile
57 @CustomTag('isolate-profile') 57 @CustomTag('isolate-profile')
58 class IsolateProfileElement extends ObservatoryElement { 58 class IsolateProfileElement extends IsolateElement {
59 IsolateProfileElement.created() : super.created(); 59 IsolateProfileElement.created() : super.created();
60 @observable int methodCountSelected = 0; 60 @observable int methodCountSelected = 0;
61 final List methodCounts = [10, 20, 50]; 61 final List methodCounts = [10, 20, 50];
62 @observable List topExclusiveCodes = toObservable([]); 62 @observable List topExclusiveCodes = toObservable([]);
63 final _id = '#tableTree'; 63 final _id = '#tableTree';
64 TableTree tree; 64 TableTree tree;
65 @published Map profile;
66
67 void profileChanged(oldValue) {
68 if (profile == null) {
69 return;
70 }
71 print('profile changed');
72 var samples = profile['samples'];
73 _loadProfileData(isolate, samples, profile);
74 _refresh(isolate);
75 }
65 76
66 void enteredView() { 77 void enteredView() {
67 var isolateId = app.locationManager.currentIsolateId();
68 var isolate = app.isolateManager.getIsolate(isolateId);
69 if (isolate == null) {
70 return;
71 }
72 tree = new TableTree(['Method', 'Exclusive', 'Caller', 'Inclusive']); 78 tree = new TableTree(['Method', 'Exclusive', 'Caller', 'Inclusive']);
73 _refresh(isolate); 79 _refresh(isolate);
74 } 80 }
75 81
76 void _startRequest() {
77 // TODO(johnmccutchan): Indicate visually.
78 }
79
80 void _endRequest() {
81 // TODO(johnmccutchan): Indicate visually.
82 }
83
84 methodCountSelectedChanged(oldValue) { 82 methodCountSelectedChanged(oldValue) {
85 var isolateId = app.locationManager.currentIsolateId();
86 var isolate = app.isolateManager.getIsolate(isolateId);
87 if (isolate == null) {
88 return;
89 }
90 _refresh(isolate); 83 _refresh(isolate);
91 } 84 }
92 85
93 void refresh(var done) { 86 void refresh(var done) {
94 var isolateId = app.locationManager.currentIsolateId(); 87 isolate.getMap('profile').then((Map profile) {
95 var isolate = app.isolateManager.getIsolate(isolateId);
96 if (isolate == null) {
97 Logger.root.info('No isolate found.');
98 return;
99 }
100 var request = '/$isolateId/profile';
101 _startRequest();
102 app.requestManager.requestMap(request).then((Map profile) {
103 assert(profile['type'] == 'Profile'); 88 assert(profile['type'] == 'Profile');
104 var samples = profile['samples']; 89 var samples = profile['samples'];
105 Logger.root.info('Profile contains ${samples} samples.'); 90 Logger.root.info('Profile contains ${samples} samples.');
106 _loadProfileData(isolate, samples, profile); 91 _loadProfileData(isolate, samples, profile);
107 _endRequest(); 92 }).catchError((e, st) {
108 }).catchError((e) { 93 Logger.root.warning('Error refreshing profile', e, st);
109 _endRequest();
110 }).whenComplete(done); 94 }).whenComplete(done);
111 } 95 }
112 96
113 void _loadProfileData(Isolate isolate, int totalSamples, Map response) { 97 void _loadProfileData(Isolate isolate, int totalSamples, Map response) {
114 isolate.profile = new Profile.fromMap(isolate, response); 98 isolate.profile = new Profile.fromMap(isolate, response);
115 _refresh(isolate); 99 _refresh(isolate);
116 } 100 }
117 101
118 void _refresh(Isolate isolate) { 102 void _refresh(Isolate isolate) {
119 _refreshTopMethods(isolate); 103 _refreshTopMethods(isolate);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 136 }
153 137
154 @observable void toggleExpanded(Event e, var detail, Element target) { 138 @observable void toggleExpanded(Event e, var detail, Element target) {
155 var row = target.parent; 139 var row = target.parent;
156 if (row is TableRowElement) { 140 if (row is TableRowElement) {
157 // Subtract 1 to get 0 based indexing. 141 // Subtract 1 to get 0 based indexing.
158 tree.toggle(row.rowIndex - 1); 142 tree.toggle(row.rowIndex - 1);
159 } 143 }
160 } 144 }
161 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698