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

Side by Side Diff: runtime/observatory/lib/src/elements/heap_profile.dart

Issue 1217823009: Make VM event streams look like real dart streams. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge with master Created 5 years, 5 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) 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:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'observatory_element.dart'; 9 import 'observatory_element.dart';
10 import 'package:observatory/app.dart'; 10 import 'package:observatory/app.dart';
(...skipping 25 matching lines...) Expand all
36 var _newPieChart; 36 var _newPieChart;
37 37
38 // Pie chart of old space usage. 38 // Pie chart of old space usage.
39 var _oldPieDataTable; 39 var _oldPieDataTable;
40 var _oldPieChart; 40 var _oldPieChart;
41 41
42 @observable ClassSortedTable classTable; 42 @observable ClassSortedTable classTable;
43 var _classTableBody; 43 var _classTableBody;
44 44
45 @published bool autoRefresh = false; 45 @published bool autoRefresh = false;
46 var _subscription; 46 var _subscriptionFuture;
47 47
48 @published Isolate isolate; 48 @published Isolate isolate;
49 @observable ServiceMap profile; 49 @observable ServiceMap profile;
50 50
51 HeapProfileElement.created() : super.created() { 51 HeapProfileElement.created() : super.created() {
52 // Create pie chart models. 52 // Create pie chart models.
53 _newPieDataTable = new DataTable(); 53 _newPieDataTable = new DataTable();
54 _newPieDataTable.addColumn('string', 'Type'); 54 _newPieDataTable.addColumn('string', 'Type');
55 _newPieDataTable.addColumn('number', 'Size'); 55 _newPieDataTable.addColumn('number', 'Size');
56 _oldPieDataTable = new DataTable(); 56 _oldPieDataTable = new DataTable();
(...skipping 29 matching lines...) Expand all
86 86
87 @override 87 @override
88 void attached() { 88 void attached() {
89 super.attached(); 89 super.attached();
90 // Grab the pie chart divs. 90 // Grab the pie chart divs.
91 _newPieChart = new Chart('PieChart', 91 _newPieChart = new Chart('PieChart',
92 shadowRoot.querySelector('#newPieChart')); 92 shadowRoot.querySelector('#newPieChart'));
93 _oldPieChart = new Chart('PieChart', 93 _oldPieChart = new Chart('PieChart',
94 shadowRoot.querySelector('#oldPieChart')); 94 shadowRoot.querySelector('#oldPieChart'));
95 _classTableBody = shadowRoot.querySelector('#classTableBody'); 95 _classTableBody = shadowRoot.querySelector('#classTableBody');
96 _subscription = app.vm.events.stream.where( 96 _subscriptionFuture =
97 (event) => event.isolate == isolate).listen(_onEvent); 97 app.vm.listenEventStream(VM.kGCStream, _onEvent);
98 } 98 }
99 99
100 @override 100 @override
101 void detached() { 101 void detached() {
102 _subscription.cancel(); 102 cancelFutureSubscription(_subscriptionFuture);
103 _subscriptionFuture = null;
103 super.detached(); 104 super.detached();
104 } 105 }
105 106
106 // Keep at most one outstanding auto-refresh RPC. 107 // Keep at most one outstanding auto-refresh RPC.
107 bool refreshAutoPending = false; 108 bool refreshAutoPending = false;
108 bool refreshAutoQueued = false; 109 bool refreshAutoQueued = false;
109 110
110 void _onEvent(ServiceEvent event) { 111 void _onEvent(ServiceEvent event) {
111 if (autoRefresh && event.kind == 'GC') { 112 assert(event.kind == 'GC');
113 if (autoRefresh) {
112 if (!refreshAutoPending) { 114 if (!refreshAutoPending) {
113 refreshAuto(); 115 refreshAuto();
114 } else { 116 } else {
115 // Remember to refresh once more, to ensure latest profile. 117 // Remember to refresh once more, to ensure latest profile.
116 refreshAutoQueued = true; 118 refreshAutoQueued = true;
117 } 119 }
118 } 120 }
119 } 121 }
120 122
121 void refreshAuto() { 123 void refreshAuto() {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 365 }
364 366
365 @observable String formattedTotalCollectionTime(bool newSpace) { 367 @observable String formattedTotalCollectionTime(bool newSpace) {
366 if (profile == null) { 368 if (profile == null) {
367 return ''; 369 return '';
368 } 370 }
369 var heap = newSpace ? isolate.newSpace : isolate.oldSpace; 371 var heap = newSpace ? isolate.newSpace : isolate.oldSpace;
370 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs'; 372 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs';
371 } 373 }
372 } 374 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/debugger.dart ('k') | runtime/observatory/lib/src/elements/ports.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698