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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartDataProvider.js

Issue 2779253003: DevTools: Show top level event initiator when a child is selected. (Closed)
Patch Set: move event parent to FlameChart data level Created 3 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
« no previous file with comments | « no previous file | no next file » | 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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 */ 137 */
138 entryFont(index) { 138 entryFont(index) {
139 return this._font; 139 return this._font;
140 } 140 }
141 141
142 reset() { 142 reset() {
143 this._currentLevel = 0; 143 this._currentLevel = 0;
144 this._timelineData = null; 144 this._timelineData = null;
145 /** @type {!Array<!SDK.TracingModel.Event|!TimelineModel.TimelineFrame|!Time lineModel.TimelineIRModel.Phases>} */ 145 /** @type {!Array<!SDK.TracingModel.Event|!TimelineModel.TimelineFrame|!Time lineModel.TimelineIRModel.Phases>} */
146 this._entryData = []; 146 this._entryData = [];
147 /** @type {!Array<!SDK.TracingModel.Event>} */
caseq 2017/03/30 22:44:51 nit: should this keep an index instead?
alph 2017/03/30 23:32:17 I tried that, but there seems to be a bit more cod
148 this._entryParent = [];
147 /** @type {!Array<!Timeline.TimelineFlameChartEntryType>} */ 149 /** @type {!Array<!Timeline.TimelineFlameChartEntryType>} */
148 this._entryTypeByLevel = []; 150 this._entryTypeByLevel = [];
149 /** @type {!Array<string>} */ 151 /** @type {!Array<string>} */
150 this._entryIndexToTitle = []; 152 this._entryIndexToTitle = [];
151 /** @type {!Array<!Timeline.TimelineFlameChartMarker>} */ 153 /** @type {!Array<!Timeline.TimelineFlameChartMarker>} */
152 this._markers = []; 154 this._markers = [];
153 /** @type {!Map<!Timeline.TimelineCategory, string>} */ 155 /** @type {!Map<!Timeline.TimelineCategory, string>} */
154 this._asyncColorByCategory = new Map(); 156 this._asyncColorByCategory = new Map();
155 /** @type {!Map<!TimelineModel.TimelineIRModel.Phases, string>} */ 157 /** @type {!Map<!TimelineModel.TimelineIRModel.Phases, string>} */
156 this._asyncColorByInteractionPhase = new Map(); 158 this._asyncColorByInteractionPhase = new Map();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 e._blackboxRoot = true; 332 e._blackboxRoot = true;
331 } 333 }
332 if (title) { 334 if (title) {
333 this._appendHeader(title, style, forceExpanded); 335 this._appendHeader(title, style, forceExpanded);
334 title = ''; 336 title = '';
335 } 337 }
336 338
337 var level = this._currentLevel + openEvents.length; 339 var level = this._currentLevel + openEvents.length;
338 if (flowEventsEnabled) 340 if (flowEventsEnabled)
339 this._appendFlowEvent(e, level); 341 this._appendFlowEvent(e, level);
340 if (e.phase !== SDK.TracingModel.Phase.FlowEnd) 342 var index = this._appendEvent(e, level);
341 this._appendEvent(e, level); 343 if (openEvents.length)
344 this._entryParent[index] = openEvents.peekLast();
342 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e)) 345 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e))
343 this._timelineData.entryTotalTimes[this._entryData.length] = undefined; 346 this._timelineData.entryTotalTimes[this._entryData.length] = undefined;
344 347
345 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); 348 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1);
346 if (e.endTime) 349 if (e.endTime)
347 openEvents.push(e); 350 openEvents.push(e);
348 } 351 }
349 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; 352 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth;
350 this._entryTypeByLevel.fill(entryType, this._currentLevel); 353 this._entryTypeByLevel.fill(entryType, this._currentLevel);
351 this._currentLevel += maxStackDepth; 354 this._currentLevel += maxStackDepth;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 * @param {!PerfUI.FlameChart.GroupStyle} style 678 * @param {!PerfUI.FlameChart.GroupStyle} style
676 * @param {boolean=} expanded 679 * @param {boolean=} expanded
677 */ 680 */
678 _appendHeader(title, style, expanded) { 681 _appendHeader(title, style, expanded) {
679 this._timelineData.groups.push({startLevel: this._currentLevel, name: title, expanded: expanded, style: style}); 682 this._timelineData.groups.push({startLevel: this._currentLevel, name: title, expanded: expanded, style: style});
680 } 683 }
681 684
682 /** 685 /**
683 * @param {!SDK.TracingModel.Event} event 686 * @param {!SDK.TracingModel.Event} event
684 * @param {number} level 687 * @param {number} level
688 * @return {number}
685 */ 689 */
686 _appendEvent(event, level) { 690 _appendEvent(event, level) {
687 var index = this._entryData.length; 691 var index = this._entryData.length;
688 this._entryData.push(event); 692 this._entryData.push(event);
689 this._timelineData.entryLevels[index] = level; 693 this._timelineData.entryLevels[index] = level;
690 this._timelineData.entryTotalTimes[index] = 694 this._timelineData.entryTotalTimes[index] =
691 event.duration || Timeline.TimelineFlameChartDataProvider.InstantEventVi sibleDurationMs; 695 event.duration || Timeline.TimelineFlameChartDataProvider.InstantEventVi sibleDurationMs;
692 this._timelineData.entryStartTimes[index] = event.startTime; 696 this._timelineData.entryStartTimes[index] = event.startTime;
693 event[Timeline.TimelineFlameChartDataProvider._indexSymbol] = index; 697 event[Timeline.TimelineFlameChartDataProvider._indexSymbol] = index;
698 return index;
694 } 699 }
695 700
696 /** 701 /**
697 * @param {!SDK.TracingModel.AsyncEvent} asyncEvent 702 * @param {!SDK.TracingModel.AsyncEvent} asyncEvent
698 * @param {number} level 703 * @param {number} level
699 */ 704 */
700 _appendAsyncEvent(asyncEvent, level) { 705 _appendAsyncEvent(asyncEvent, level) {
701 if (SDK.TracingModel.isNestableAsyncPhase(asyncEvent.phase)) { 706 if (SDK.TracingModel.isNestableAsyncPhase(asyncEvent.phase)) {
702 // FIXME: also add steps once we support event nesting in the FlameChart. 707 // FIXME: also add steps once we support event nesting in the FlameChart.
703 this._appendEvent(asyncEvent, level); 708 this._appendEvent(asyncEvent, level);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 863
859 /** 864 /**
860 * @param {number} entryIndex 865 * @param {number} entryIndex
861 * @return {boolean} 866 * @return {boolean}
862 */ 867 */
863 buildFlowForInitiator(entryIndex) { 868 buildFlowForInitiator(entryIndex) {
864 if (this._lastInitiatorEntry === entryIndex) 869 if (this._lastInitiatorEntry === entryIndex)
865 return false; 870 return false;
866 this._lastInitiatorEntry = entryIndex; 871 this._lastInitiatorEntry = entryIndex;
867 var event = this.eventByIndex(entryIndex); 872 var event = this.eventByIndex(entryIndex);
868 var initiator = event && TimelineModel.TimelineData.forEvent(event).initiato r();
869 if (initiator && !this._isVisible(initiator))
870 initiator = null;
871 var td = this._timelineData; 873 var td = this._timelineData;
872 if (td.flowStartTimes.length || initiator) { 874 td.flowStartTimes = [];
873 td.flowStartTimes = []; 875 td.flowStartLevels = [];
874 td.flowStartLevels = []; 876 td.flowEndTimes = [];
875 td.flowEndTimes = []; 877 td.flowEndLevels = [];
876 td.flowEndLevels = []; 878 // Find the closest ancestor with an initiator.
879 var initiator;
880 for (; event; event = this._eventParent(event)) {
881 if (!this._isVisible(event))
882 continue;
883 initiator = TimelineModel.TimelineData.forEvent(event).initiator();
884 if (initiator)
885 break;
877 } 886 }
878 if (!initiator) 887 if (!initiator || !this._isVisible(initiator))
879 return true; 888 return true;
889 var eventIndex = event[Timeline.TimelineFlameChartDataProvider._indexSymbol] ;
880 var initiatorIndex = initiator[Timeline.TimelineFlameChartDataProvider._inde xSymbol]; 890 var initiatorIndex = initiator[Timeline.TimelineFlameChartDataProvider._inde xSymbol];
881 var eventIndex = event[Timeline.TimelineFlameChartDataProvider._indexSymbol] ;
882 td.flowStartTimes.push(initiator.endTime || initiator.startTime); 891 td.flowStartTimes.push(initiator.endTime || initiator.startTime);
883 td.flowStartLevels.push(td.entryLevels[initiatorIndex]); 892 td.flowStartLevels.push(td.entryLevels[initiatorIndex]);
884 td.flowEndTimes.push(event.startTime); 893 td.flowEndTimes.push(event.startTime);
885 td.flowEndLevels.push(td.entryLevels[eventIndex]); 894 td.flowEndLevels.push(td.entryLevels[eventIndex]);
886 return true; 895 return true;
887 } 896 }
888 897
889 /** 898 /**
899 * @param {!SDK.TracingModel.Event} event
900 * @return {?SDK.TracingModel.Event}
901 */
902 _eventParent(event) {
903 return this._entryParent[event[Timeline.TimelineFlameChartDataProvider._inde xSymbol]] || null;
904 }
905
906 /**
890 * @param {number} entryIndex 907 * @param {number} entryIndex
891 * @return {?SDK.TracingModel.Event} 908 * @return {?SDK.TracingModel.Event}
892 */ 909 */
893 eventByIndex(entryIndex) { 910 eventByIndex(entryIndex) {
894 return this._entryType(entryIndex) === Timeline.TimelineFlameChartEntryType. Event ? 911 return this._entryType(entryIndex) === Timeline.TimelineFlameChartEntryType. Event ?
895 /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryIndex]) : 912 /** @type {!SDK.TracingModel.Event} */ (this._entryData[entryIndex]) :
896 null; 913 null;
897 } 914 }
898 }; 915 };
899 916
900 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; 917 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001;
901 Timeline.TimelineFlameChartDataProvider._indexSymbol = Symbol('index'); 918 Timeline.TimelineFlameChartDataProvider._indexSymbol = Symbol('index');
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698