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

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

Issue 1846713003: Add call tree filter to Observatory CPU profile tree (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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) 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 Class allocationProfileClass; 540 Class allocationProfileClass;
541 541
542 final CpuProfile profile = new CpuProfile(); 542 final CpuProfile profile = new CpuProfile();
543 final Stopwatch _stopWatch = new Stopwatch(); 543 final Stopwatch _stopWatch = new Stopwatch();
544 } 544 }
545 545
546 @CustomTag('stack-trace-tree-config') 546 @CustomTag('stack-trace-tree-config')
547 class StackTraceTreeConfigElement extends ObservatoryElement { 547 class StackTraceTreeConfigElement extends ObservatoryElement {
548 StackTraceTreeConfigElement.created() : super.created(); 548 StackTraceTreeConfigElement.created() : super.created();
549 549
550 attached() {
551 super.attached();
552 var filterElement = shadowRoot.querySelector('#filterInput');
553 keyDownSubscription = filterElement.onKeyDown.listen(_onKeyDown);
554 blurSubscription = filterElement.onBlur.listen(_onBlur);
555 }
556
557 detached() {
558 super.detached();
559 keyDownSubscription?.cancel();
560 blurSubscription?.cancel();
561 }
562
563 void _onKeyDown(KeyboardEvent keyEvent) {
564 if (keyEvent.keyCode == 13) {
565 // On enter, update the filter string.
566 filterString =
567 (shadowRoot.querySelector('#filterInput') as InputElement).value;
568 if (onTreeConfigChange == null) {
569 return;
570 }
571 onTreeConfigChange(modeSelector, directionSelector, filterString);
572 }
573 }
574
575 void _onBlur(Event event) {
576 // Input box has lost focus, update the display to match the active
577 // filter string.
578 (shadowRoot.querySelector('#filterInput') as InputElement).value =
579 filterString;
580 }
581
550 void modeSelectorChanged(oldValue) { 582 void modeSelectorChanged(oldValue) {
551 if (onTreeConfigChange == null) { 583 if (onTreeConfigChange == null) {
552 return; 584 return;
553 } 585 }
554 onTreeConfigChange(modeSelector, directionSelector); 586 onTreeConfigChange(modeSelector, directionSelector, filterString);
555 } 587 }
556 588
557 void directionSelectorChanged(oldValue) { 589 void directionSelectorChanged(oldValue) {
558 if (onTreeConfigChange == null) { 590 if (onTreeConfigChange == null) {
559 return; 591 return;
560 } 592 }
561 onTreeConfigChange(modeSelector, directionSelector); 593 onTreeConfigChange(modeSelector, directionSelector, filterString);
562 } 594 }
563 595
564 Function onTreeConfigChange; 596 Function onTreeConfigChange;
597 StreamSubscription keyDownSubscription;
598 StreamSubscription blurSubscription;
565 @observable bool show = true; 599 @observable bool show = true;
566 @observable bool showModeSelector = true; 600 @observable bool showModeSelector = true;
567 @observable bool showDirectionSelector = true; 601 @observable bool showDirectionSelector = true;
602 @observable bool showFilter = true;
568 @observable String modeSelector = 'Function'; 603 @observable String modeSelector = 'Function';
569 @observable String directionSelector = 'Up'; 604 @observable String directionSelector = 'Up';
605 @observable String filterString;
570 } 606 }
571 607
572 class FunctionCallTreeNodeRow extends VirtualTreeRow { 608 class FunctionCallTreeNodeRow extends VirtualTreeRow {
573 final CpuProfile profile; 609 final CpuProfile profile;
574 final FunctionCallTreeNode node; 610 final FunctionCallTreeNode node;
575 final String selfPercent; 611 final String selfPercent;
576 final String totalPercent; 612 final String totalPercent;
577 final String percent; 613 final String percent;
578 614
579 FunctionCallTreeNodeRow(VirtualTree tree, 615 FunctionCallTreeNodeRow(VirtualTree tree,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 update() { 762 update() {
727 if (sampleBufferControlElement != null) { 763 if (sampleBufferControlElement != null) {
728 sampleBufferControlElement.reload(isolate); 764 sampleBufferControlElement.reload(isolate);
729 } 765 }
730 } 766 }
731 767
732 onSampleBufferChange(CpuProfile sampleBuffer) { 768 onSampleBufferChange(CpuProfile sampleBuffer) {
733 _renderTask.queue(); 769 _renderTask.queue();
734 } 770 }
735 771
736 onTreeConfigChange(String modeSelector, String directionSelector) { 772 onTreeConfigChange(String modeSelector,
773 String directionSelector,
774 String filterString) {
737 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; 775 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive;
738 if (directionSelector != 'Up') { 776 if (directionSelector != 'Up') {
739 direction = ProfileTreeDirection.Inclusive; 777 direction = ProfileTreeDirection.Inclusive;
740 } 778 }
741 ProfileTreeMode mode = ProfileTreeMode.Function; 779 ProfileTreeMode mode = ProfileTreeMode.Function;
742 if (modeSelector == 'Code') { 780 if (modeSelector == 'Code') {
743 mode = ProfileTreeMode.Code; 781 mode = ProfileTreeMode.Code;
744 } 782 }
783 // Clear the filter.
784 cpuProfileVirtualTreeElement.filter = null;
785 if (filterString != null) {
786 filterString = filterString.trim();
787 if (filterString.isNotEmpty) {
788 cpuProfileVirtualTreeElement.filter = (CallTreeNode node) {
789 return node.name.contains(filterString);
790 };
791 }
792 }
745 cpuProfileVirtualTreeElement.direction = direction; 793 cpuProfileVirtualTreeElement.direction = direction;
746 cpuProfileVirtualTreeElement.mode = mode; 794 cpuProfileVirtualTreeElement.mode = mode;
747 _renderTask.queue(); 795 _renderTask.queue();
748 } 796 }
749 797
750 Future clearCpuProfile() async { 798 Future clearCpuProfile() async {
751 await isolate.invokeRpc('_clearCpuProfile', { }); 799 await isolate.invokeRpc('_clearCpuProfile', { });
752 _updateTask.queue(); 800 _updateTask.queue();
753 return new Future.value(null); 801 return new Future.value(null);
754 } 802 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 _clearView(); 1009 _clearView();
962 if (sampleBufferControlElement != null) { 1010 if (sampleBufferControlElement != null) {
963 sampleBufferControlElement.reload(isolate).whenComplete(checkParameters); 1011 sampleBufferControlElement.reload(isolate).whenComplete(checkParameters);
964 } 1012 }
965 } 1013 }
966 1014
967 onSampleBufferChange(CpuProfile sampleBuffer) { 1015 onSampleBufferChange(CpuProfile sampleBuffer) {
968 _renderTask.queue(); 1016 _renderTask.queue();
969 } 1017 }
970 1018
971 onTreeConfigChange(String modeSelector, String directionSelector) { 1019 onTreeConfigChange(String modeSelector,
1020 String directionSelector,
1021 String filterString) {
972 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; 1022 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive;
973 if (directionSelector != 'Up') { 1023 if (directionSelector != 'Up') {
974 direction = ProfileTreeDirection.Inclusive; 1024 direction = ProfileTreeDirection.Inclusive;
975 } 1025 }
976 ProfileTreeMode mode = ProfileTreeMode.Function; 1026 ProfileTreeMode mode = ProfileTreeMode.Function;
977 if (modeSelector == 'Code') { 1027 if (modeSelector == 'Code') {
978 mode = ProfileTreeMode.Code; 1028 mode = ProfileTreeMode.Code;
979 } 1029 }
980 cpuProfileTreeElement.direction = direction; 1030 cpuProfileTreeElement.direction = direction;
981 cpuProfileTreeElement.mode = mode; 1031 cpuProfileTreeElement.mode = mode;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 return; 1489 return;
1440 } 1490 }
1441 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); 1491 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive');
1442 if (tree == null) { 1492 if (tree == null) {
1443 return; 1493 return;
1444 } 1494 }
1445 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); 1495 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root);
1446 codeTree.initialize(rootRow); 1496 codeTree.initialize(rootRow);
1447 } 1497 }
1448 } 1498 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/cpu_profile/cpu_profile.dart ('k') | runtime/observatory/lib/src/elements/cpu_profile.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698