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

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

Issue 1283413002: Fix table cpu profile to work properly with non-dart functions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 Future refresh() { 862 Future refresh() {
863 _updateTask.queue(); 863 _updateTask.queue();
864 return new Future.value(null); 864 return new Future.value(null);
865 } 865 }
866 866
867 render() { 867 render() {
868 _updateView(); 868 _updateView();
869 } 869 }
870 870
871 checkParameters() { 871 checkParameters() {
872 var functionId = app.locationManager.uri.queryParameters['functionId'];
873 if (functionId == null) {
874 _focusOnFunction(null);
875 return;
876 }
877 if (isolate == null) { 872 if (isolate == null) {
878 return; 873 return;
879 } 874 }
880 isolate.getObject(functionId).then((func) => _focusOnFunction(func)); 875 var functionId = app.locationManager.uri.queryParameters['functionId'];
876 var functionName =
877 app.locationManager.uri.queryParameters['functionName'];
878 if (functionId == '') {
879 // Fallback to searching by name.
880 _focusOnFunction(_findFunction(functionName));
881 } else {
882 if (functionId == null) {
883 _focusOnFunction(null);
884 return;
885 }
886 isolate.getObject(functionId).then((func) => _focusOnFunction(func));
887 }
881 } 888 }
882 889
883 _clearView() { 890 _clearView() {
884 profileTable.clearRows(); 891 profileTable.clearRows();
885 _renderTable(); 892 _renderTable();
886 } 893 }
887 894
888 _updateView() { 895 _updateView() {
889 _buildFunctionTable(); 896 _buildFunctionTable();
890 _renderTable(); 897 _renderTable();
(...skipping 15 matching lines...) Expand all
906 TableSectionElement tableBody = $['profile-table']; 913 TableSectionElement tableBody = $['profile-table'];
907 var row = _findFunctionRow(function); 914 var row = _findFunctionRow(function);
908 if (row == -1) { 915 if (row == -1) {
909 return; 916 return;
910 } 917 }
911 tableBody.children[row].classes.remove('shake'); 918 tableBody.children[row].classes.remove('shake');
912 // trigger reflow. 919 // trigger reflow.
913 tableBody.children[row].offsetHeight; 920 tableBody.children[row].offsetHeight;
914 tableBody.children[row].scrollIntoView(ScrollAlignment.CENTER); 921 tableBody.children[row].scrollIntoView(ScrollAlignment.CENTER);
915 tableBody.children[row].classes.add('shake'); 922 tableBody.children[row].classes.add('shake');
923 // Focus on clicked function.
924 _focusOnFunction(function);
916 } 925 }
917 926
918 _clearFocusedFunction() { 927 _clearFocusedFunction() {
919 TableSectionElement tableBody = $['profile-table']; 928 TableSectionElement tableBody = $['profile-table'];
920 // Clear current focus. 929 // Clear current focus.
921 if (focusedRow != null) { 930 if (focusedRow != null) {
922 tableBody.children[focusedRow].classes.remove('focused'); 931 tableBody.children[focusedRow].classes.remove('focused');
923 } 932 }
924 focusedRow = null; 933 focusedRow = null;
925 focusedFunction = null; 934 focusedFunction = null;
926 } 935 }
927 936
937 ServiceFunction _findFunction(String functionName) {
938 for (var func in profile.functions) {
939 if (func.function.name == functionName) {
940 return func.function;
941 }
942 }
943 return null;
944 }
945
928 _focusOnFunction(ServiceFunction function) { 946 _focusOnFunction(ServiceFunction function) {
929 if (focusedFunction == function) { 947 if (focusedFunction == function) {
930 // Do nothing. 948 // Do nothing.
931 return; 949 return;
932 } 950 }
933 951
934 _clearFocusedFunction(); 952 _clearFocusedFunction();
935 953
936 if (function == null) { 954 if (function == null) {
937 _updateFunctionTreeView(); 955 _updateFunctionTreeView();
(...skipping 17 matching lines...) Expand all
955 _buildCallersTable(focusedFunction); 973 _buildCallersTable(focusedFunction);
956 _buildCalleesTable(focusedFunction); 974 _buildCalleesTable(focusedFunction);
957 } 975 }
958 976
959 _onRowClick(TableRowElement tr) { 977 _onRowClick(TableRowElement tr) {
960 var tableBody = $['profile-table']; 978 var tableBody = $['profile-table'];
961 var row = profileTable.rowFromIndex(tableBody.children.indexOf(tr)); 979 var row = profileTable.rowFromIndex(tableBody.children.indexOf(tr));
962 var function = row.values[NameSortedTable.FUNCTION_COLUMN]; 980 var function = row.values[NameSortedTable.FUNCTION_COLUMN];
963 app.locationManager.goReplacingParameters( 981 app.locationManager.goReplacingParameters(
964 { 982 {
965 'functionId': function.id 983 'functionId': function.id,
984 'functionName': function.vmName
966 } 985 }
967 ); 986 );
968 } 987 }
969 988
970 _renderTable() { 989 _renderTable() {
971 profileTable._updateTableView($['profile-table'], 990 profileTable._updateTableView($['profile-table'],
972 profileTable._makeFunctionRow, 991 profileTable._makeFunctionRow,
973 _onRowClick, 992 _onRowClick,
974 NameSortedTable.FUNCTION_SPACER_COLUMNS, 993 NameSortedTable.FUNCTION_SPACER_COLUMNS,
975 NameSortedTable.FUNCTION_COLUMN); 994 NameSortedTable.FUNCTION_COLUMN);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 return; 1209 return;
1191 } 1210 }
1192 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive'); 1211 var tree = profile.loadCodeTree(exclusive ? 'exclusive' : 'inclusive');
1193 if (tree == null) { 1212 if (tree == null) {
1194 return; 1213 return;
1195 } 1214 }
1196 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root); 1215 var rootRow = new CodeProfileTreeRow(codeTree, null, profile, tree.root);
1197 codeTree.initialize(rootRow); 1216 codeTree.initialize(rootRow);
1198 } 1217 }
1199 } 1218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698