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

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

Issue 205713004: Add isolate tag-profile and better handling of errors (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_view_element; 5 library isolate_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/app.dart';
9 import 'package:observatory/service.dart'; 10 import 'package:observatory/service.dart';
10 import 'package:polymer/polymer.dart'; 11 import 'package:polymer/polymer.dart';
11 12
13 class TagProfileChart {
14 var _table = new DataTable();
15 var _chart;
16
17 void update(TagProfile tagProfile) {
18 if (_table.columns == 0) {
19 // Initialize.
20 _table.addColumn('string', 'Time');
21 for (var tagName in tagProfile.names) {
22 if (tagName == 'Idle') {
23 // Skip Idle tag.
24 continue;
25 }
26 _table.addColumn('number', tagName);
27 }
28 }
29 _table.clearRows();
30 var idleIndex = tagProfile.names.indexOf('Idle');
31 assert(idleIndex != -1);
32 var t = tagProfile.updatedAtSeconds;
33 for (var i = 0; i < tagProfile.snapshots.length; i++) {
34 var snapshotTime = tagProfile.snapshots[i].seconds;
35 var row = [];
36 if (snapshotTime > 0.0) {
37 row.add('t ${(snapshotTime - t).toStringAsFixed(2)}');
38 } else {
39 row.add('');
40 }
41 var sum = tagProfile.snapshots[i].sum;
42 if (sum == 0) {
43 for (var j = 0; j < tagProfile.snapshots[i].counters.length; j++) {
44 if (j == idleIndex) {
45 // Skip idle.
46 continue;
47 }
48 row.add(0);
49 }
50 } else {
51 for (var j = 0; j < tagProfile.snapshots[i].counters.length; j++) {
52 if (j == idleIndex) {
53 // Skip idle.
54 continue;
55 }
56 var percentage = tagProfile.snapshots[i].counters[j] / sum * 100.0;
57 row.add(percentage.toInt());
58 }
59 }
60 _table.addRow(row);
61 }
62 }
63
64 void draw(var element) {
65 if (_chart == null) {
66 assert(element != null);
67 _chart = new Chart('SteppedAreaChart', element);
68 _chart.options['isStacked'] = true;
69 _chart.options['connectSteps'] = false;
70 _chart.options['vAxis'] = {
71 'minValue': 0.0,
72 'maxValue': 100.0,
73 };
74 }
75 _chart.draw(_table);
76 }
77 }
78
12 @CustomTag('isolate-view') 79 @CustomTag('isolate-view')
13 class IsolateViewElement extends ObservatoryElement { 80 class IsolateViewElement extends ObservatoryElement {
14 @published Isolate isolate; 81 @published Isolate isolate;
82 Timer _updateTimer;
83 TagProfileChart tagProfileChart = new TagProfileChart();
15 IsolateViewElement.created() : super.created(); 84 IsolateViewElement.created() : super.created();
16 85
17 Future<ServiceObject> eval(String text) { 86 Future<ServiceObject> eval(String text) {
18 return isolate.get( 87 return isolate.get(
19 isolate.rootLib.id + "/eval?expr=${Uri.encodeComponent(text)}"); 88 isolate.rootLib.id + "/eval?expr=${Uri.encodeComponent(text)}");
20 } 89 }
21 90
91 void enteredView() {
92 super.enteredView();
93 // Start a periodic timer to update the isolate summary once a second.
94 _updateTimer = new Timer.periodic(new Duration(seconds: 1), (_) {
95 isolate.updateTagProfile().then((tagProfile) {
96 tagProfileChart.update(tagProfile);
97 _drawTagProfileChart();
98 });
99 });
100 }
101
102 void leftView() {
103 super.leftView();
104 _updateTimer.cancel();
105 }
106
107 void _drawTagProfileChart() {
108 var element = shadowRoot.querySelector('#tagProfileChart');
109 if (element != null) {
110 tagProfileChart.draw(element);
111 }
112 }
113
22 void refresh(var done) { 114 void refresh(var done) {
23 isolate.reload().whenComplete(done); 115 isolate.reload().whenComplete(done);
24 } 116 }
25 117
26 void resume(var a, var b, var c) { 118 void resume(var a, var b, var c) {
27 isolate.get("resume").then((result) { 119 isolate.get("resume").then((result) {
28 // TODO(turnidge): Instead of asserting here, handling errors 120 // TODO(turnidge): Instead of asserting here, handling errors
29 // properly. 121 // properly.
30 assert(result.serviceType == 'Success'); 122 assert(result.serviceType == 'Success');
31 isolate.reload(); 123 isolate.reload();
32 }); 124 });
33 } 125 }
34 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698