| OLD | NEW |
| 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 cpu_profile_element; | 5 library cpu_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/service.dart'; | 10 import 'package:observatory/service.dart'; |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 this.profile, | 581 this.profile, |
| 582 FunctionCallTreeNode node) | 582 FunctionCallTreeNode node) |
| 583 : node = node, | 583 : node = node, |
| 584 selfPercent = Utils.formatPercentNormalized(node.profileFunction.normali
zedExclusiveTicks), | 584 selfPercent = Utils.formatPercentNormalized(node.profileFunction.normali
zedExclusiveTicks), |
| 585 totalPercent = Utils.formatPercentNormalized(node.profileFunction.normal
izedInclusiveTicks), | 585 totalPercent = Utils.formatPercentNormalized(node.profileFunction.normal
izedInclusiveTicks), |
| 586 percent = Utils.formatPercentNormalized(node.percentage), | 586 percent = Utils.formatPercentNormalized(node.percentage), |
| 587 super(tree, depth) { | 587 super(tree, depth) { |
| 588 } | 588 } |
| 589 | 589 |
| 590 void onRender(DivElement rowDiv) { | 590 void onRender(DivElement rowDiv) { |
| 591 rowDiv.children.add(makeGap(ems:0.1)); |
| 591 rowDiv.children.add( | 592 rowDiv.children.add( |
| 592 makeText(totalPercent, toolTip: 'global % on stack')); | 593 makeText(totalPercent, toolTip: 'global % on stack')); |
| 593 rowDiv.children.add(makeGap()); | 594 rowDiv.children.add(makeGap()); |
| 594 rowDiv.children.add( | 595 rowDiv.children.add( |
| 595 makeText(selfPercent, toolTip: 'global % executing')); | 596 makeText(selfPercent, toolTip: 'global % executing')); |
| 596 rowDiv.children.add(makeGap()); | 597 rowDiv.children.add(makeGap()); |
| 597 rowDiv.children.add(makeIndenter(colored: false)); | 598 rowDiv.children.add(makeIndenter(colored: false)); |
| 598 rowDiv.children.add(makeColorBar()); | 599 rowDiv.children.add(makeColorBar()); |
| 599 rowDiv.children.add(makeGap(ems: 1.0)); | 600 rowDiv.children.add(makeGap(ems: 1.0)); |
| 600 rowDiv.children.add(makeExpander()); | 601 rowDiv.children.add(makeExpander()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 this.profile, | 634 this.profile, |
| 634 CodeCallTreeNode node) | 635 CodeCallTreeNode node) |
| 635 : node = node, | 636 : node = node, |
| 636 selfPercent = Utils.formatPercentNormalized(node.profileCode.normalizedE
xclusiveTicks), | 637 selfPercent = Utils.formatPercentNormalized(node.profileCode.normalizedE
xclusiveTicks), |
| 637 totalPercent = Utils.formatPercentNormalized(node.profileCode.normalized
InclusiveTicks), | 638 totalPercent = Utils.formatPercentNormalized(node.profileCode.normalized
InclusiveTicks), |
| 638 percent = Utils.formatPercentNormalized(node.percentage), | 639 percent = Utils.formatPercentNormalized(node.percentage), |
| 639 super(tree, depth) { | 640 super(tree, depth) { |
| 640 } | 641 } |
| 641 | 642 |
| 642 void onRender(DivElement rowDiv) { | 643 void onRender(DivElement rowDiv) { |
| 644 rowDiv.children.add(makeGap(ems:0.1)); |
| 643 rowDiv.children.add( | 645 rowDiv.children.add( |
| 644 makeText(totalPercent, toolTip: 'global % on stack')); | 646 makeText(totalPercent, toolTip: 'global % on stack')); |
| 645 rowDiv.children.add(makeGap()); | 647 rowDiv.children.add(makeGap()); |
| 646 rowDiv.children.add( | 648 rowDiv.children.add( |
| 647 makeText(selfPercent, toolTip: 'global % executing')); | 649 makeText(selfPercent, toolTip: 'global % executing')); |
| 648 rowDiv.children.add(makeGap()); | 650 rowDiv.children.add(makeGap()); |
| 649 rowDiv.children.add(makeIndenter(colored: false)); | 651 rowDiv.children.add(makeIndenter(colored: false)); |
| 650 rowDiv.children.add(makeColorBar()); | 652 rowDiv.children.add(makeColorBar()); |
| 651 rowDiv.children.add(makeGap(ems: 1.0)); | 653 rowDiv.children.add(makeGap(ems: 1.0)); |
| 652 rowDiv.children.add(makeExpander()); | 654 rowDiv.children.add(makeExpander()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 super.detached(); | 704 super.detached(); |
| 703 if (_resizeSubscription != null) { | 705 if (_resizeSubscription != null) { |
| 704 _resizeSubscription.cancel(); | 706 _resizeSubscription.cancel(); |
| 705 } | 707 } |
| 706 } | 708 } |
| 707 | 709 |
| 708 _updateSize() { | 710 _updateSize() { |
| 709 var applySize = (e) { | 711 var applySize = (e) { |
| 710 Rectangle rect = e.getBoundingClientRect(); | 712 Rectangle rect = e.getBoundingClientRect(); |
| 711 final totalHeight = window.innerHeight; | 713 final totalHeight = window.innerHeight; |
| 712 final top = rect.top; | |
| 713 final bottomMargin = 200; | 714 final bottomMargin = 200; |
| 714 final mainHeight = totalHeight - top - bottomMargin; | 715 final mainHeight = totalHeight - bottomMargin; |
| 715 e.style.setProperty('height', '${mainHeight}px'); | 716 e.style.setProperty('height', '${mainHeight}px'); |
| 716 }; | 717 }; |
| 717 HtmlElement e2 = $['cpuProfileVirtualTree']; | 718 HtmlElement e2 = $['cpuProfileVirtualTree']; |
| 718 applySize(e2); | 719 applySize(e2); |
| 719 } | 720 } |
| 720 | 721 |
| 721 isolateChanged(oldValue) { | 722 isolateChanged(oldValue) { |
| 722 _updateTask.queue(); | 723 _updateTask.queue(); |
| 723 } | 724 } |
| 724 | 725 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 Code, | 1266 Code, |
| 1266 Function, | 1267 Function, |
| 1267 } | 1268 } |
| 1268 | 1269 |
| 1269 @CustomTag('cpu-profile-virtual-tree') | 1270 @CustomTag('cpu-profile-virtual-tree') |
| 1270 class CpuProfileVirtualTreeElement extends ObservatoryElement { | 1271 class CpuProfileVirtualTreeElement extends ObservatoryElement { |
| 1271 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; | 1272 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; |
| 1272 ProfileTreeMode mode = ProfileTreeMode.Function; | 1273 ProfileTreeMode mode = ProfileTreeMode.Function; |
| 1273 CpuProfile profile; | 1274 CpuProfile profile; |
| 1274 VirtualTree virtualTree; | 1275 VirtualTree virtualTree; |
| 1275 FunctionCallTreeNodeFilter functionFilter; | 1276 CallTreeNodeFilter filter; |
| 1277 StreamSubscription _resizeSubscription; |
| 1276 @observable bool show = true; | 1278 @observable bool show = true; |
| 1277 | 1279 |
| 1278 CpuProfileVirtualTreeElement.created() : super.created(); | 1280 CpuProfileVirtualTreeElement.created() : super.created(); |
| 1279 | 1281 |
| 1282 attached() { |
| 1283 super.attached(); |
| 1284 _resizeSubscription = window.onResize.listen((_) => _updateSize()); |
| 1285 } |
| 1286 |
| 1287 detached() { |
| 1288 super.detached(); |
| 1289 _resizeSubscription?.cancel(); |
| 1290 } |
| 1291 |
| 1280 void render() { | 1292 void render() { |
| 1281 _updateView(); | 1293 _updateView(); |
| 1282 } | 1294 } |
| 1283 | 1295 |
| 1284 showChanged(oldValue) { | 1296 showChanged(oldValue) { |
| 1285 var treeTable = shadowRoot.querySelector('#treeTable'); | 1297 var treeTable = shadowRoot.querySelector('#treeTable'); |
| 1286 assert(treeTable != null); | 1298 assert(treeTable != null); |
| 1287 treeTable.style.display = show ? 'table' : 'none'; | 1299 treeTable.style.display = show ? 'table' : 'none'; |
| 1288 } | 1300 } |
| 1289 | 1301 |
| 1290 void _updateView() { | 1302 void _updateView() { |
| 1303 _updateSize(); |
| 1291 virtualTree?.clear(); | 1304 virtualTree?.clear(); |
| 1292 virtualTree?.uninstall(); | 1305 virtualTree?.uninstall(); |
| 1293 virtualTree = null; | 1306 virtualTree = null; |
| 1294 bool exclusive = direction == ProfileTreeDirection.Exclusive; | 1307 bool exclusive = direction == ProfileTreeDirection.Exclusive; |
| 1295 if (mode == ProfileTreeMode.Code) { | 1308 if (mode == ProfileTreeMode.Code) { |
| 1296 _buildCodeTree(exclusive); | 1309 _buildCodeTree(exclusive); |
| 1297 } else { | 1310 } else { |
| 1298 assert(mode == ProfileTreeMode.Function); | 1311 assert(mode == ProfileTreeMode.Function); |
| 1299 _buildFunctionTree(exclusive); | 1312 _buildFunctionTree(exclusive); |
| 1300 } | 1313 } |
| 1301 virtualTree?.refresh(); | 1314 virtualTree?.refresh(); |
| 1302 } | 1315 } |
| 1303 | 1316 |
| 1317 void _updateSize() { |
| 1318 var treeBody = shadowRoot.querySelector('#tree'); |
| 1319 assert(treeBody != null); |
| 1320 int windowHeight = window.innerHeight - 32; |
| 1321 treeBody.style.height = '${windowHeight}px'; |
| 1322 } |
| 1323 |
| 1304 void _buildFunctionTree(bool exclusive) { | 1324 void _buildFunctionTree(bool exclusive) { |
| 1305 var treeBody = shadowRoot.querySelector('#tree'); | 1325 var treeBody = shadowRoot.querySelector('#tree'); |
| 1306 assert(treeBody != null); | 1326 assert(treeBody != null); |
| 1307 virtualTree = new VirtualTree(32, treeBody); | 1327 virtualTree = new VirtualTree(32, treeBody); |
| 1308 if (profile == null) { | 1328 if (profile == null) { |
| 1309 return; | 1329 return; |
| 1310 } | 1330 } |
| 1311 var tree = profile.loadFunctionTree(exclusive ? 'exclusive' : 'inclusive'); | 1331 var tree = profile.loadFunctionTree(exclusive ? 'exclusive' : 'inclusive'); |
| 1312 if (tree == null) { | 1332 if (tree == null) { |
| 1313 return; | 1333 return; |
| 1314 } | 1334 } |
| 1315 if (functionFilter != null) { | 1335 if (filter != null) { |
| 1316 tree = tree.filtered(functionFilter); | 1336 tree = tree.filtered(filter); |
| 1317 } | 1337 } |
| 1318 for (var child in tree.root.children) { | 1338 for (var child in tree.root.children) { |
| 1319 virtualTree.rows.add( | 1339 virtualTree.rows.add( |
| 1320 new FunctionCallTreeNodeRow(virtualTree, 0, profile, child)); | 1340 new FunctionCallTreeNodeRow(virtualTree, 0, profile, child)); |
| 1321 } | 1341 } |
| 1322 if (virtualTree.rows.length == 1) { | 1342 if (virtualTree.rows.length == 1) { |
| 1323 virtualTree.rows[0].expanded = true; | 1343 virtualTree.rows[0].expanded = true; |
| 1324 } | 1344 } |
| 1325 } | 1345 } |
| 1326 | 1346 |
| 1327 void _buildCodeTree(bool exclusive) { | 1347 void _buildCodeTree(bool exclusive) { |
| 1328 var treeBody = shadowRoot.querySelector('#tree'); | 1348 var treeBody = shadowRoot.querySelector('#tree'); |
| 1329 assert(treeBody != null); | 1349 assert(treeBody != null); |
| 1330 virtualTree = new VirtualTree(32, treeBody); | 1350 virtualTree = new VirtualTree(32, treeBody); |
| 1331 if (profile == null) { | 1351 if (profile == null) { |
| 1332 return; | 1352 return; |
| 1333 } | 1353 } |
| 1334 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); | 1354 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); |
| 1335 if (tree == null) { | 1355 if (tree == null) { |
| 1336 return; | 1356 return; |
| 1337 } | 1357 } |
| 1358 if (filter != null) { |
| 1359 tree = tree.filtered(filter); |
| 1360 } |
| 1338 for (var child in tree.root.children) { | 1361 for (var child in tree.root.children) { |
| 1339 virtualTree.rows.add( | 1362 virtualTree.rows.add( |
| 1340 new CodeCallTreeNodeRow(virtualTree, 0, profile, child)); | 1363 new CodeCallTreeNodeRow(virtualTree, 0, profile, child)); |
| 1341 } | 1364 } |
| 1342 if (virtualTree.rows.length == 1) { | 1365 if (virtualTree.rows.length == 1) { |
| 1343 virtualTree.rows[0].expanded = true; | 1366 virtualTree.rows[0].expanded = true; |
| 1344 } | 1367 } |
| 1345 } | 1368 } |
| 1346 } | 1369 } |
| 1347 | 1370 |
| 1348 @CustomTag('cpu-profile-tree') | 1371 @CustomTag('cpu-profile-tree') |
| 1349 class CpuProfileTreeElement extends ObservatoryElement { | 1372 class CpuProfileTreeElement extends ObservatoryElement { |
| 1350 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; | 1373 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; |
| 1351 ProfileTreeMode mode = ProfileTreeMode.Function; | 1374 ProfileTreeMode mode = ProfileTreeMode.Function; |
| 1352 CpuProfile profile; | 1375 CpuProfile profile; |
| 1353 TableTree codeTree; | 1376 TableTree codeTree; |
| 1354 TableTree functionTree; | 1377 TableTree functionTree; |
| 1355 FunctionCallTreeNodeFilter functionFilter; | 1378 CallTreeNodeFilter functionFilter; |
| 1356 @observable bool show = true; | 1379 @observable bool show = true; |
| 1357 | 1380 |
| 1358 CpuProfileTreeElement.created() : super.created(); | 1381 CpuProfileTreeElement.created() : super.created(); |
| 1359 | 1382 |
| 1360 void render() { | 1383 void render() { |
| 1361 _updateView(); | 1384 _updateView(); |
| 1362 } | 1385 } |
| 1363 | 1386 |
| 1364 showChanged(oldValue) { | 1387 showChanged(oldValue) { |
| 1365 var treeTable = shadowRoot.querySelector('#treeTable'); | 1388 var treeTable = shadowRoot.querySelector('#treeTable'); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 return; | 1439 return; |
| 1417 } | 1440 } |
| 1418 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); | 1441 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); |
| 1419 if (tree == null) { | 1442 if (tree == null) { |
| 1420 return; | 1443 return; |
| 1421 } | 1444 } |
| 1422 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); | 1445 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); |
| 1423 codeTree.initialize(rootRow); | 1446 codeTree.initialize(rootRow); |
| 1424 } | 1447 } |
| 1425 } | 1448 } |
| OLD | NEW |