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

Side by Side Diff: Source/devtools/front_end/profiler/CPUProfileView.js

Issue 887673002: DevTools: CPU profiler sunburst view (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/profiler/d3js_trace/LICENSE » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 columns.push({id: "self", title: WebInspector.UIString("Self"), width: "120p x", sort: WebInspector.DataGrid.Order.Descending, sortable: true}); 44 columns.push({id: "self", title: WebInspector.UIString("Self"), width: "120p x", sort: WebInspector.DataGrid.Order.Descending, sortable: true});
45 columns.push({id: "total", title: WebInspector.UIString("Total"), width: "12 0px", sortable: true}); 45 columns.push({id: "total", title: WebInspector.UIString("Total"), width: "12 0px", sortable: true});
46 columns.push({id: "function", title: WebInspector.UIString("Function"), disc losure: true, sortable: true}); 46 columns.push({id: "function", title: WebInspector.UIString("Function"), disc losure: true, sortable: true});
47 47
48 this.dataGrid = new WebInspector.DataGrid(columns); 48 this.dataGrid = new WebInspector.DataGrid(columns);
49 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortProfile, this); 49 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortProfile, this);
50 50
51 this.viewSelectComboBox = new WebInspector.StatusBarComboBox(this._changeVie w.bind(this)); 51 this.viewSelectComboBox = new WebInspector.StatusBarComboBox(this._changeVie w.bind(this));
52 52
53 var options = {}; 53 var options = {};
54 options[WebInspector.CPUProfileView._TypeSunburst] = this.viewSelectComboBox .createOption(WebInspector.UIString("Sunburst"), "", WebInspector.CPUProfileView ._TypeSunburst);
54 options[WebInspector.CPUProfileView._TypeFlame] = this.viewSelectComboBox.cr eateOption(WebInspector.UIString("Chart"), "", WebInspector.CPUProfileView._Type Flame); 55 options[WebInspector.CPUProfileView._TypeFlame] = this.viewSelectComboBox.cr eateOption(WebInspector.UIString("Chart"), "", WebInspector.CPUProfileView._Type Flame);
55 options[WebInspector.CPUProfileView._TypeHeavy] = this.viewSelectComboBox.cr eateOption(WebInspector.UIString("Heavy (Bottom Up)"), "", WebInspector.CPUProfi leView._TypeHeavy); 56 options[WebInspector.CPUProfileView._TypeHeavy] = this.viewSelectComboBox.cr eateOption(WebInspector.UIString("Heavy (Bottom Up)"), "", WebInspector.CPUProfi leView._TypeHeavy);
56 options[WebInspector.CPUProfileView._TypeTree] = this.viewSelectComboBox.cre ateOption(WebInspector.UIString("Tree (Top Down)"), "", WebInspector.CPUProfileV iew._TypeTree); 57 options[WebInspector.CPUProfileView._TypeTree] = this.viewSelectComboBox.cre ateOption(WebInspector.UIString("Tree (Top Down)"), "", WebInspector.CPUProfileV iew._TypeTree);
57 58
58 var optionName = this._viewType.get() || WebInspector.CPUProfileView._TypeFl ame; 59 var optionName = this._viewType.get() || WebInspector.CPUProfileView._TypeFl ame;
59 var option = options[optionName] || options[WebInspector.CPUProfileView._Typ eFlame]; 60 var option = options[optionName] || options[WebInspector.CPUProfileView._Typ eFlame];
60 this.viewSelectComboBox.select(option); 61 this.viewSelectComboBox.select(option);
61 62
62 this.focusButton = new WebInspector.StatusBarButton(WebInspector.UIString("F ocus selected function."), "focus-status-bar-item"); 63 this.focusButton = new WebInspector.StatusBarButton(WebInspector.UIString("F ocus selected function."), "focus-status-bar-item");
63 this.focusButton.setEnabled(false); 64 this.focusButton.setEnabled(false);
(...skipping 10 matching lines...) Expand all
74 this._profileHeader = profileHeader; 75 this._profileHeader = profileHeader;
75 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultFormatter(30)); 76 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultFormatter(30));
76 77
77 this.profile = new WebInspector.CPUProfileDataModel(profileHeader._profile | | profileHeader.protocolProfile()); 78 this.profile = new WebInspector.CPUProfileDataModel(profileHeader._profile | | profileHeader.protocolProfile());
78 79
79 this._changeView(); 80 this._changeView();
80 if (this._flameChart) 81 if (this._flameChart)
81 this._flameChart.update(); 82 this._flameChart.update();
82 } 83 }
83 84
85 WebInspector.CPUProfileView._TypeSunburst = "Sunburst";
84 WebInspector.CPUProfileView._TypeFlame = "Flame"; 86 WebInspector.CPUProfileView._TypeFlame = "Flame";
85 WebInspector.CPUProfileView._TypeTree = "Tree"; 87 WebInspector.CPUProfileView._TypeTree = "Tree";
86 WebInspector.CPUProfileView._TypeHeavy = "Heavy"; 88 WebInspector.CPUProfileView._TypeHeavy = "Heavy";
87 89
88 /** 90 /**
89 * @interface 91 * @interface
90 */ 92 */
91 WebInspector.CPUProfileView.Searchable = function() 93 WebInspector.CPUProfileView.Searchable = function()
92 { 94 {
93 } 95 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 264
263 _ensureFlameChartCreated: function() 265 _ensureFlameChartCreated: function()
264 { 266 {
265 if (this._flameChart) 267 if (this._flameChart)
266 return; 268 return;
267 this._dataProvider = new WebInspector.CPUFlameChartDataProvider(this.pro file, this._profileHeader.target()); 269 this._dataProvider = new WebInspector.CPUFlameChartDataProvider(this.pro file, this._profileHeader.target());
268 this._flameChart = new WebInspector.CPUProfileFlameChart(this._dataProvi der); 270 this._flameChart = new WebInspector.CPUProfileFlameChart(this._dataProvi der);
269 this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySe lected, this._onEntrySelected.bind(this)); 271 this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySe lected, this._onEntrySelected.bind(this));
270 }, 272 },
271 273
274 _ensureSunburstChartCreated: function()
275 {
276 if (this._sunburstChart)
277 return;
278 // this._sunburstDataProvider = new WebInspector.CPUFlameChartDataProvid er(this.profile, this._profileHeader.target());
279 this._sunburstChart = new WebInspector.CPUProfileSunburstChart(this.prof ile);
280 // this._flameChart.addEventListener(WebInspector.FlameChart.Events.Entry Selected, this._onEntrySelected.bind(this));
281 },
282
272 /** 283 /**
273 * @param {!WebInspector.Event} event 284 * @param {!WebInspector.Event} event
274 */ 285 */
275 _onEntrySelected: function(event) 286 _onEntrySelected: function(event)
276 { 287 {
277 var entryIndex = event.data; 288 var entryIndex = event.data;
278 var node = this._dataProvider._entryNodes[entryIndex]; 289 var node = this._dataProvider._entryNodes[entryIndex];
279 var target = this._profileHeader.target(); 290 var target = this._profileHeader.target();
280 if (!node || !node.scriptId || !target) 291 if (!node || !node.scriptId || !target)
281 return; 292 return;
282 var script = target.debuggerModel.scriptForId(node.scriptId); 293 var script = target.debuggerModel.scriptForId(node.scriptId);
283 if (!script) 294 if (!script)
284 return; 295 return;
285 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (scri pt.target().debuggerModel.createRawLocation(script, node.lineNumber, 0)); 296 var location = /** @type {!WebInspector.DebuggerModel.Location} */ (scri pt.target().debuggerModel.createRawLocation(script, node.lineNumber, 0));
286 WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLo cationToUILocation(location)); 297 WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLo cationToUILocation(location));
287 }, 298 },
288 299
289 _changeView: function() 300 _changeView: function()
290 { 301 {
291 if (!this.profile) 302 if (!this.profile)
292 return; 303 return;
293 304
294 this._searchableView.closeSearch(); 305 this._searchableView.closeSearch();
295 306
296 if (this._visibleView) 307 if (this._visibleView)
297 this._visibleView.detach(); 308 this._visibleView.detach();
298 309
299 this._viewType.set(this.viewSelectComboBox.selectedOption().value); 310 this._viewType.set(this.viewSelectComboBox.selectedOption().value);
300 switch (this._viewType.get()) { 311 switch (this._viewType.get()) {
312 case WebInspector.CPUProfileView._TypeSunburst:
313 this._ensureSunburstChartCreated();
314 this._visibleView = this._sunburstChart;
315 this._searchableElement = this._sunburstChart;
316 break;
301 case WebInspector.CPUProfileView._TypeFlame: 317 case WebInspector.CPUProfileView._TypeFlame:
302 this._ensureFlameChartCreated(); 318 this._ensureFlameChartCreated();
303 this._visibleView = this._flameChart; 319 this._visibleView = this._flameChart;
304 this._searchableElement = this._flameChart; 320 this._searchableElement = this._flameChart;
305 break; 321 break;
306 case WebInspector.CPUProfileView._TypeTree: 322 case WebInspector.CPUProfileView._TypeTree:
307 this.profileDataGridTree = this._getTopDownProfileDataGridTree(); 323 this.profileDataGridTree = this._getTopDownProfileDataGridTree();
308 this._sortProfile(); 324 this._sortProfile();
309 this._visibleView = this.dataGrid; 325 this._visibleView = this.dataGrid;
310 this._searchableElement = this.profileDataGridTree; 326 this._searchableElement = this.profileDataGridTree;
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 _notifyTempFileReady: function() 819 _notifyTempFileReady: function()
804 { 820 {
805 if (this._onTempFileReady) { 821 if (this._onTempFileReady) {
806 this._onTempFileReady(); 822 this._onTempFileReady();
807 this._onTempFileReady = null; 823 this._onTempFileReady = null;
808 } 824 }
809 }, 825 },
810 826
811 __proto__: WebInspector.ProfileHeader.prototype 827 __proto__: WebInspector.ProfileHeader.prototype
812 } 828 }
829
830
831 /**
832 * @constructor
833 * @extends {WebInspector.VBox}
834 * @param {!WebInspector.CPUProfileDataModel} profile
835 */
836 WebInspector.CPUProfileSunburstChart = function(profile)
837 {
838 WebInspector.VBox.call(this);
839 this.element.id = "cpu-sunburst-chart";
840 this._rootNode = this._convertToD3Trace(profile.profileHead);
841
842 var iframe = this.element.createChild("iframe", "vbox flex-auto visible");
843 iframe.src = "chrome-devtools://devtools/bundled/profiler/d3js_trace/index.h tml";
844 function onFrameLoad()
845 {
846 iframe.contentWindow.postMessage(this._rootNode, "*");
847 }
848 iframe.onload = onFrameLoad.bind(this);
849 }
850
851 WebInspector.CPUProfileSunburstChart.prototype = {
852 _convertToD3Trace: function(node)
853 {
854 var result = {
855 name: node.functionName,
856 size: node.hitCount,
857 children: []
858 };
859 for (var i = 0; i < node.children.length; i++) {
860 var child = this._convertToD3Trace(node.children[i]);
861 result.size += child.size;
862 result.children.push(child);
863 }
864 return result;
865 },
866
867 __proto__: WebInspector.VBox.prototype
868 };
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/profiler/d3js_trace/LICENSE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698