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

Unified Diff: runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart

Issue 192443004: Complete the switch to ServiceObject (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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart
diff --git a/runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart b/runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart
index 8a2961ba02b9a4df3b05247970141ff23792a001..39092b38d45c9b63653b64d32d0a708f787956c8 100644
--- a/runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart
+++ b/runtime/bin/vmservice/client/lib/src/elements/isolate_profile.dart
@@ -5,25 +5,28 @@
library isolate_profile_element;
import 'dart:html';
-import 'isolate_element.dart';
-import 'package:logging/logging.dart';
+import 'observatory_element.dart';
+import 'package:observatory/service.dart';
import 'package:observatory/app.dart';
import 'package:polymer/polymer.dart';
class ProfileCallerTreeRow extends TableTreeRow {
- final Isolate isolate;
- @observable final Code code;
+ final ServiceMap profile;
+ @reflectable final Code code;
static String formatPercent(num a, num total) {
var percent = 100.0 * (a / total);
return '${percent.toStringAsFixed(2)}%';
}
- ProfileCallerTreeRow(this.isolate, this.code, ProfileCallerTreeRow parent) :
+ ProfileCallerTreeRow(this.profile, this.code, ProfileCallerTreeRow parent) :
super(parent) {
+ assert(profile != null);
+ assert(code != null);
+ var totalSamples = profile['samples'];
// When the row is created, fill out the columns.
columns.add(
- formatPercent(code.exclusiveTicks, isolate.profile.totalSamples));
+ formatPercent(code.exclusiveTicks, totalSamples));
if (parent == null) {
// Fill with dummy data.
columns.add('');
@@ -32,8 +35,6 @@ class ProfileCallerTreeRow extends TableTreeRow {
var totalParentCalls = parent.code.sumCallersCount();
columns.add(formatPercent(totalAttributedCalls, totalParentCalls));
}
- columns.add(
- formatPercent(code.inclusiveTicks, isolate.profile.totalSamples));
}
void onShow() {
@@ -44,7 +45,7 @@ class ProfileCallerTreeRow extends TableTreeRow {
// Create child rows on demand.
code.callers.forEach((CodeCallCount codeCaller) {
var row =
- new ProfileCallerTreeRow(isolate, codeCaller.code, this);
+ new ProfileCallerTreeRow(profile, codeCaller.code, this);
children.add(row);
});
}
@@ -55,81 +56,73 @@ class ProfileCallerTreeRow extends TableTreeRow {
/// Displays an IsolateProfile
@CustomTag('isolate-profile')
-class IsolateProfileElement extends IsolateElement {
+class IsolateProfileElement extends ObservatoryElement {
IsolateProfileElement.created() : super.created();
+ @published ServiceMap profile;
+ @reflectable final topExclusiveCodes = new ObservableList<Code>();
@observable int methodCountSelected = 0;
+ @observable String sampleCount = '';
+ @observable String refreshTime = '';
+
final List methodCounts = [10, 20, 50];
- @observable List topExclusiveCodes = toObservable([]);
final _id = '#tableTree';
TableTree tree;
- @published Map profile;
- @observable String sampleCount = '';
- @observable String refreshTime = '';
void profileChanged(oldValue) {
if (profile == null) {
return;
}
- print('profile changed');
- var samples = profile['samples'];
- _loadProfileData(isolate, samples, profile);
- _refresh(isolate);
+ var totalSamples = profile['samples'];
+ var now = new DateTime.now();
+ sampleCount = totalSamples.toString();
+ refreshTime = now.toString();
+ profile.isolate.processProfile(profile);
+ _update();
}
void enteredView() {
- tree = new TableTree(['Method', 'Exclusive', 'Caller', 'Inclusive']);
- _refresh(isolate);
+ tree = new TableTree(['Method', 'Exclusive', 'Caller']);
+ _update();
}
methodCountSelectedChanged(oldValue) {
- _refresh(isolate);
+ _update();
}
void refresh(var done) {
- isolate.getMap('profile').then((Map profile) {
- assert(profile['type'] == 'Profile');
- var samples = profile['samples'];
- Logger.root.info('Profile contains ${samples} samples.');
- _loadProfileData(isolate, samples, profile);
- }).catchError((e, st) {
- Logger.root.warning('Error refreshing profile', e, st);
+ profile.isolate.get('profile').then((ServiceMap m) {
+ // Assert we got back the a profile.
+ assert(m.serviceType == 'Profile');
+ profile = m;
}).whenComplete(done);
}
- void _loadProfileData(Isolate isolate, int totalSamples, Map response) {
- sampleCount = totalSamples.toString();
- var now = new DateTime.now();
- refreshTime = now.toString();
- isolate.profile = new Profile.fromMap(isolate, response);
- _refresh(isolate);
+ void _update() {
+ if (profile == null) {
+ return;
+ }
+ _refreshTopMethods();
+ _rebuildTree();
}
- void _refresh(Isolate isolate) {
- _refreshTopMethods(isolate);
- _refreshTree(isolate);
+ void _refreshTopMethods() {
+ assert(profile != null);
+ var count = methodCounts[methodCountSelected];
+ topExclusiveCodes.clear();
+ topExclusiveCodes.addAll(profile.isolate.codes.topExclusive(count));
}
- void _refreshTree(Isolate isolate) {
+ void _rebuildTree() {
+ assert(profile != null);
var rootChildren = [];
for (var code in topExclusiveCodes) {
- var row = new ProfileCallerTreeRow(isolate, code, null);
+ var row = new ProfileCallerTreeRow(profile, code, null);
rootChildren.add(row);
}
tree.initialize(rootChildren);
notifyPropertyChange(#tree, null, tree);
}
-
- void _refreshTopMethods(Isolate isolate) {
- topExclusiveCodes.clear();
- if ((isolate == null) || (isolate.profile == null)) {
- return;
- }
- var count = methodCounts[methodCountSelected];
- var topExclusive = isolate.profile.topExclusive(count);
- topExclusiveCodes.addAll(topExclusive);
- }
-
@observable String padding(TableTreeRow row) {
return 'padding-left: ${row.depth * 16}px;';
}
@@ -147,4 +140,5 @@ class IsolateProfileElement extends IsolateElement {
tree.toggle(row.rowIndex - 1);
}
}
+
}

Powered by Google App Engine
This is Rietveld 408576698