| OLD | NEW |
| 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 'observatory_element.dart'; | 8 import 'observatory_element.dart'; |
| 9 import 'package:observatory/app.dart'; | 9 import 'package:observatory/app.dart'; |
| 10 import 'package:observatory/service.dart'; | 10 import 'package:observatory/service.dart'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 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 ServiceMap profile; | 45 @published ServiceMap profile; |
| 46 @published bool autoRefresh = false; |
| 47 var _subscription; |
| 46 | 48 |
| 47 @observable Isolate isolate; | 49 @observable Isolate isolate; |
| 48 | 50 |
| 49 HeapProfileElement.created() : super.created() { | 51 HeapProfileElement.created() : super.created() { |
| 50 // Create pie chart models. | 52 // Create pie chart models. |
| 51 _newPieDataTable = new DataTable(); | 53 _newPieDataTable = new DataTable(); |
| 52 _newPieDataTable.addColumn('string', 'Type'); | 54 _newPieDataTable.addColumn('string', 'Type'); |
| 53 _newPieDataTable.addColumn('number', 'Size'); | 55 _newPieDataTable.addColumn('number', 'Size'); |
| 54 _oldPieDataTable = new DataTable(); | 56 _oldPieDataTable = new DataTable(); |
| 55 _oldPieDataTable.addColumn('string', 'Type'); | 57 _oldPieDataTable.addColumn('string', 'Type'); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 | 86 |
| 85 @override | 87 @override |
| 86 void attached() { | 88 void attached() { |
| 87 super.attached(); | 89 super.attached(); |
| 88 // Grab the pie chart divs. | 90 // Grab the pie chart divs. |
| 89 _newPieChart = new Chart('PieChart', | 91 _newPieChart = new Chart('PieChart', |
| 90 shadowRoot.querySelector('#newPieChart')); | 92 shadowRoot.querySelector('#newPieChart')); |
| 91 _oldPieChart = new Chart('PieChart', | 93 _oldPieChart = new Chart('PieChart', |
| 92 shadowRoot.querySelector('#oldPieChart')); | 94 shadowRoot.querySelector('#oldPieChart')); |
| 93 _classTableBody = shadowRoot.querySelector('#classTableBody'); | 95 _classTableBody = shadowRoot.querySelector('#classTableBody'); |
| 96 _subscription = app.vm.events.stream.where( |
| 97 (event) => event.isolate == isolate).listen(_onEvent); |
| 94 } | 98 } |
| 95 | 99 |
| 100 @override |
| 101 void detached() { |
| 102 _subscription.cancel((){}); |
| 103 super.detached(); |
| 104 } |
| 105 |
| 106 void _onEvent(ServiceEvent event) { |
| 107 if (autoRefresh && event.eventType == 'GC') { |
| 108 refresh((){}); |
| 109 } |
| 110 } |
| 111 |
| 96 void _updatePieCharts() { | 112 void _updatePieCharts() { |
| 97 assert(profile != null); | 113 assert(profile != null); |
| 98 _newPieDataTable.clearRows(); | 114 _newPieDataTable.clearRows(); |
| 99 var isolate = profile.isolate; | 115 var isolate = profile.isolate; |
| 100 _newPieDataTable.addRow(['Used', isolate.newSpace.used]); | 116 _newPieDataTable.addRow(['Used', isolate.newSpace.used]); |
| 101 _newPieDataTable.addRow(['Free', | 117 _newPieDataTable.addRow(['Free', |
| 102 isolate.newSpace.capacity - isolate.newSpace.used]); | 118 isolate.newSpace.capacity - isolate.newSpace.used]); |
| 103 _newPieDataTable.addRow(['External', isolate.newSpace.external]); | 119 _newPieDataTable.addRow(['External', isolate.newSpace.external]); |
| 104 _oldPieDataTable.clearRows(); | 120 _oldPieDataTable.clearRows(); |
| 105 _oldPieDataTable.addRow(['Used', isolate.oldSpace.used]); | 121 _oldPieDataTable.addRow(['Used', isolate.oldSpace.used]); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 332 } |
| 317 | 333 |
| 318 @observable String formattedTotalCollectionTime(bool newSpace) { | 334 @observable String formattedTotalCollectionTime(bool newSpace) { |
| 319 if (profile == null) { | 335 if (profile == null) { |
| 320 return ''; | 336 return ''; |
| 321 } | 337 } |
| 322 var heap = newSpace ? profile.isolate.newSpace : profile.isolate.oldSpace; | 338 var heap = newSpace ? profile.isolate.newSpace : profile.isolate.oldSpace; |
| 323 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs'; | 339 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs'; |
| 324 } | 340 } |
| 325 } | 341 } |
| OLD | NEW |