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/models.dart' as M; |
10 import 'package:observatory/service.dart'; | 11 import 'package:observatory/service.dart'; |
11 import 'package:observatory/app.dart'; | 12 import 'package:observatory/app.dart'; |
12 import 'package:observatory/cpu_profile.dart'; | 13 import 'package:observatory/cpu_profile.dart'; |
13 import 'package:observatory/elements.dart'; | 14 import 'package:observatory/elements.dart'; |
14 import 'package:polymer/polymer.dart'; | 15 import 'package:polymer/polymer.dart'; |
15 | 16 |
16 List<String> sorted(Set<String> attributes) { | 17 List<String> sorted(Set<String> attributes) { |
17 var list = attributes.toList(); | 18 var list = attributes.toList(); |
18 list.sort(); | 19 list.sort(); |
19 return list; | 20 return list; |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 gap.text = ' '; | 341 gap.text = ' '; |
341 functionRow.children.add(gap); | 342 functionRow.children.add(gap); |
342 | 343 |
343 for (var attribute in sorted(node.attributes)) { | 344 for (var attribute in sorted(node.attributes)) { |
344 functionRow.children.add(newAttributeBox(attribute)); | 345 functionRow.children.add(newAttributeBox(attribute)); |
345 } | 346 } |
346 | 347 |
347 makeInfoBox(); | 348 makeInfoBox(); |
348 functionRow.children.add(infoBox); | 349 functionRow.children.add(infoBox); |
349 | 350 |
350 if (node.profileFunction.function.kind.hasDartCode()) { | 351 if (M.hasDartCode(node.profileFunction.function.kind)) { |
351 infoBox.children.add(div('Code for current node')); | 352 infoBox.children.add(div('Code for current node')); |
352 infoBox.children.add(br()); | 353 infoBox.children.add(br()); |
353 var totalTicks = node.totalCodesTicks; | 354 var totalTicks = node.totalCodesTicks; |
354 var numCodes = node.codes.length; | 355 var numCodes = node.codes.length; |
355 for (var i = 0; i < numCodes; i++) { | 356 for (var i = 0; i < numCodes; i++) { |
356 var codeRowSpan = new DivElement(); | 357 var codeRowSpan = new DivElement(); |
357 codeRowSpan.style.paddingLeft = '1em'; | 358 codeRowSpan.style.paddingLeft = '1em'; |
358 infoBox.children.add(codeRowSpan); | 359 infoBox.children.add(codeRowSpan); |
359 var nodeCode = node.codes[i]; | 360 var nodeCode = node.codes[i]; |
360 var ticks = nodeCode.ticks; | 361 var ticks = nodeCode.ticks; |
(...skipping 25 matching lines...) Expand all Loading... |
386 infoBox.children.add(br()); | 387 infoBox.children.add(br()); |
387 infoBox.children.add(memberList); | 388 infoBox.children.add(memberList); |
388 infoBox.children.add(br()); | 389 infoBox.children.add(br()); |
389 ProfileTreeRow._addToMemberList(memberList, { | 390 ProfileTreeRow._addToMemberList(memberList, { |
390 'Exclusive ticks' : node.profileFunction.formattedExclusiveTicks, | 391 'Exclusive ticks' : node.profileFunction.formattedExclusiveTicks, |
391 'Cpu time' : node.profileFunction.formattedCpuTime, | 392 'Cpu time' : node.profileFunction.formattedCpuTime, |
392 'Inclusive ticks' : node.profileFunction.formattedInclusiveTicks, | 393 'Inclusive ticks' : node.profileFunction.formattedInclusiveTicks, |
393 'Call stack time' : node.profileFunction.formattedOnStackTime, | 394 'Call stack time' : node.profileFunction.formattedOnStackTime, |
394 }); | 395 }); |
395 | 396 |
396 if (node.profileFunction.function.kind.hasDartCode()) { | 397 if (M.hasDartCode(node.profileFunction.function.kind)) { |
397 infoBox.children.add(div('Code containing function')); | 398 infoBox.children.add(div('Code containing function')); |
398 infoBox.children.add(br()); | 399 infoBox.children.add(br()); |
399 var totalTicks = profile.sampleCount; | 400 var totalTicks = profile.sampleCount; |
400 var codes = node.profileFunction.profileCodes; | 401 var codes = node.profileFunction.profileCodes; |
401 var numCodes = codes.length; | 402 var numCodes = codes.length; |
402 for (var i = 0; i < numCodes; i++) { | 403 for (var i = 0; i < numCodes; i++) { |
403 var codeRowSpan = new DivElement(); | 404 var codeRowSpan = new DivElement(); |
404 codeRowSpan.style.paddingLeft = '1em'; | 405 codeRowSpan.style.paddingLeft = '1em'; |
405 infoBox.children.add(codeRowSpan); | 406 infoBox.children.add(codeRowSpan); |
406 var profileCode = codes[i]; | 407 var profileCode = codes[i]; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 return 'coldProfile'; | 641 return 'coldProfile'; |
641 } | 642 } |
642 } | 643 } |
643 | 644 |
644 FunctionCallTreeNodeRow(VirtualTree tree, | 645 FunctionCallTreeNodeRow(VirtualTree tree, |
645 int depth, | 646 int depth, |
646 this.profile, | 647 this.profile, |
647 FunctionCallTreeNode node) | 648 FunctionCallTreeNode node) |
648 : node = node, | 649 : node = node, |
649 super(tree, depth) { | 650 super(tree, depth) { |
650 if ((node.profileFunction.function.kind == FunctionKind.kTag) && | 651 if ((node.profileFunction.function.kind == M.FunctionKind.tag) && |
651 (node.profileFunction.normalizedExclusiveTicks == 0) && | 652 (node.profileFunction.normalizedExclusiveTicks == 0) && |
652 (node.profileFunction.normalizedInclusiveTicks == 0)) { | 653 (node.profileFunction.normalizedInclusiveTicks == 0)) { |
653 selfPercent = ''; | 654 selfPercent = ''; |
654 totalPercent = ''; | 655 totalPercent = ''; |
655 } else { | 656 } else { |
656 selfPercent = Utils.formatPercentNormalized( | 657 selfPercent = Utils.formatPercentNormalized( |
657 node.profileFunction.normalizedExclusiveTicks); | 658 node.profileFunction.normalizedExclusiveTicks); |
658 totalPercent = Utils.formatPercentNormalized( | 659 totalPercent = Utils.formatPercentNormalized( |
659 node.profileFunction.normalizedInclusiveTicks); | 660 node.profileFunction.normalizedInclusiveTicks); |
660 } | 661 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 return 'coldProfile'; | 729 return 'coldProfile'; |
729 } | 730 } |
730 } | 731 } |
731 | 732 |
732 CodeCallTreeNodeRow(VirtualTree tree, | 733 CodeCallTreeNodeRow(VirtualTree tree, |
733 int depth, | 734 int depth, |
734 this.profile, | 735 this.profile, |
735 CodeCallTreeNode node) | 736 CodeCallTreeNode node) |
736 : node = node, | 737 : node = node, |
737 super(tree, depth) { | 738 super(tree, depth) { |
738 if ((node.profileCode.code.kind == CodeKind.Tag) && | 739 if ((node.profileCode.code.kind == M.CodeKind.tag) && |
739 (node.profileCode.normalizedExclusiveTicks == 0) && | 740 (node.profileCode.normalizedExclusiveTicks == 0) && |
740 (node.profileCode.normalizedInclusiveTicks == 0)) { | 741 (node.profileCode.normalizedInclusiveTicks == 0)) { |
741 selfPercent = ''; | 742 selfPercent = ''; |
742 totalPercent = ''; | 743 totalPercent = ''; |
743 } else { | 744 } else { |
744 selfPercent = Utils.formatPercentNormalized( | 745 selfPercent = Utils.formatPercentNormalized( |
745 node.profileCode.normalizedExclusiveTicks); | 746 node.profileCode.normalizedExclusiveTicks); |
746 totalPercent = Utils.formatPercentNormalized( | 747 totalPercent = Utils.formatPercentNormalized( |
747 node.profileCode.normalizedInclusiveTicks); | 748 node.profileCode.normalizedInclusiveTicks); |
748 } | 749 } |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 return; | 1567 return; |
1567 } | 1568 } |
1568 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); | 1569 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); |
1569 if (tree == null) { | 1570 if (tree == null) { |
1570 return; | 1571 return; |
1571 } | 1572 } |
1572 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); | 1573 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); |
1573 codeTree.initialize(rootRow); | 1574 codeTree.initialize(rootRow); |
1574 } | 1575 } |
1575 } | 1576 } |
OLD | NEW |