| OLD | NEW |
| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 (Object.assign({}, defaultGroupStyle, {shareHeaderLine: false})); | 68 (Object.assign({}, defaultGroupStyle, {shareHeaderLine: false})); |
| 69 this._headerLevel2 = /** @type {!PerfUI.FlameChart.GroupStyle} */ | 69 this._headerLevel2 = /** @type {!PerfUI.FlameChart.GroupStyle} */ |
| 70 (Object.assign({}, defaultGroupStyle, {padding: 2, nestingLevel: 1, coll
apsible: false})); | 70 (Object.assign({}, defaultGroupStyle, {padding: 2, nestingLevel: 1, coll
apsible: false})); |
| 71 this._staticHeader = /** @type {!PerfUI.FlameChart.GroupStyle} */ | 71 this._staticHeader = /** @type {!PerfUI.FlameChart.GroupStyle} */ |
| 72 (Object.assign({}, defaultGroupStyle, {collapsible: false})); | 72 (Object.assign({}, defaultGroupStyle, {collapsible: false})); |
| 73 this._interactionsHeaderLevel1 = /** @type {!PerfUI.FlameChart.GroupStyle} *
/ | 73 this._interactionsHeaderLevel1 = /** @type {!PerfUI.FlameChart.GroupStyle} *
/ |
| 74 (Object.assign({useFirstLineForOverview: true}, defaultGroupStyle)); | 74 (Object.assign({useFirstLineForOverview: true}, defaultGroupStyle)); |
| 75 this._interactionsHeaderLevel2 = /** @type {!PerfUI.FlameChart.GroupStyle} *
/ | 75 this._interactionsHeaderLevel2 = /** @type {!PerfUI.FlameChart.GroupStyle} *
/ |
| 76 (Object.assign({}, defaultGroupStyle, {padding: 2, nestingLevel: 1})); | 76 (Object.assign({}, defaultGroupStyle, {padding: 2, nestingLevel: 1})); |
| 77 | 77 |
| 78 /** @type {!Map<!SDK.TracingModel.Event, number>} */ | 78 /** @type {!Map<string, number>} */ |
| 79 this._flowEventIndexByEvent = new Map(); | 79 this._flowEventIndexById = new Map(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * @param {?Timeline.PerformanceModel} performanceModel | 83 * @param {?Timeline.PerformanceModel} performanceModel |
| 84 */ | 84 */ |
| 85 setModel(performanceModel) { | 85 setModel(performanceModel) { |
| 86 this.reset(); | 86 this.reset(); |
| 87 this._performanceModel = performanceModel; | 87 this._performanceModel = performanceModel; |
| 88 this._model = performanceModel && performanceModel.timelineModel(); | 88 this._model = performanceModel && performanceModel.timelineModel(); |
| 89 } | 89 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 * @return {!PerfUI.FlameChart.TimelineData} | 171 * @return {!PerfUI.FlameChart.TimelineData} |
| 172 */ | 172 */ |
| 173 timelineData() { | 173 timelineData() { |
| 174 if (this._timelineData) | 174 if (this._timelineData) |
| 175 return this._timelineData; | 175 return this._timelineData; |
| 176 | 176 |
| 177 this._timelineData = new PerfUI.FlameChart.TimelineData([], [], [], []); | 177 this._timelineData = new PerfUI.FlameChart.TimelineData([], [], [], []); |
| 178 if (!this._model) | 178 if (!this._model) |
| 179 return this._timelineData; | 179 return this._timelineData; |
| 180 | 180 |
| 181 this._flowEventIndexByEvent.clear(); | 181 this._flowEventIndexById.clear(); |
| 182 | 182 |
| 183 this._minimumBoundary = this._model.minimumRecordTime(); | 183 this._minimumBoundary = this._model.minimumRecordTime(); |
| 184 this._timeSpan = this._model.isEmpty() ? 1000 : this._model.maximumRecordTim
e() - this._minimumBoundary; | 184 this._timeSpan = this._model.isEmpty() ? 1000 : this._model.maximumRecordTim
e() - this._minimumBoundary; |
| 185 this._currentLevel = 0; | 185 this._currentLevel = 0; |
| 186 | 186 |
| 187 this._appendHeader(Common.UIString('Frames'), this._staticHeader); | 187 this._appendHeader(Common.UIString('Frames'), this._staticHeader); |
| 188 this._appendFrameBars(this._performanceModel.frames()); | 188 this._appendFrameBars(this._performanceModel.frames()); |
| 189 | 189 |
| 190 this._appendHeader(Common.UIString('Interactions'), this._interactionsHeader
Level1); | 190 this._appendHeader(Common.UIString('Interactions'), this._interactionsHeader
Level1); |
| 191 this._appendInteractionRecords(); | 191 this._appendInteractionRecords(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 compositorThreads[i].events, Common.UIString('Rasterizer Thread %d',
i), this._headerLevel2, | 225 compositorThreads[i].events, Common.UIString('Rasterizer Thread %d',
i), this._headerLevel2, |
| 226 eventEntryType); | 226 eventEntryType); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 this._appendGPUEvents(); | 229 this._appendGPUEvents(); |
| 230 | 230 |
| 231 otherThreads.forEach( | 231 otherThreads.forEach( |
| 232 thread => this._appendThreadTimelineData( | 232 thread => this._appendThreadTimelineData( |
| 233 thread.name || Common.UIString('Thread %d', thread.id), thread.event
s, thread.asyncEventsByGroup)); | 233 thread.name || Common.UIString('Thread %d', thread.id), thread.event
s, thread.asyncEventsByGroup)); |
| 234 | 234 |
| 235 this._appendFlowData(); | |
| 236 this._flowEventIndexByEvent.clear(); | |
| 237 | |
| 238 for (let extensionIndex = 0; extensionIndex < this._extensionInfo.length; ex
tensionIndex++) | 235 for (let extensionIndex = 0; extensionIndex < this._extensionInfo.length; ex
tensionIndex++) |
| 239 this._innerAppendExtensionEvents(extensionIndex); | 236 this._innerAppendExtensionEvents(extensionIndex); |
| 240 | 237 |
| 241 /** | 238 /** |
| 242 * @param {!Timeline.TimelineFlameChartMarker} a | 239 * @param {!Timeline.TimelineFlameChartMarker} a |
| 243 * @param {!Timeline.TimelineFlameChartMarker} b | 240 * @param {!Timeline.TimelineFlameChartMarker} b |
| 244 */ | 241 */ |
| 245 function compareStartTime(a, b) { | 242 function compareStartTime(a, b) { |
| 246 return a.startTime() - b.startTime(); | 243 return a.startTime() - b.startTime(); |
| 247 } | 244 } |
| 248 | 245 |
| 249 this._markers.sort(compareStartTime); | 246 this._markers.sort(compareStartTime); |
| 250 this._timelineData.markers = this._markers; | 247 this._timelineData.markers = this._markers; |
| 248 this._flowEventIndexById.clear(); |
| 251 | 249 |
| 252 return this._timelineData; | 250 return this._timelineData; |
| 253 } | 251 } |
| 254 | 252 |
| 255 /** | 253 /** |
| 256 * @override | 254 * @override |
| 257 * @return {number} | 255 * @return {number} |
| 258 */ | 256 */ |
| 259 minimumBoundary() { | 257 minimumBoundary() { |
| 260 return this._minimumBoundary; | 258 return this._minimumBoundary; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 var parent = openEvents.peekLast(); | 327 var parent = openEvents.peekLast(); |
| 330 if (parent && parent._blackboxRoot) | 328 if (parent && parent._blackboxRoot) |
| 331 continue; | 329 continue; |
| 332 e._blackboxRoot = true; | 330 e._blackboxRoot = true; |
| 333 } | 331 } |
| 334 if (title) { | 332 if (title) { |
| 335 this._appendHeader(title, style, forceExpanded); | 333 this._appendHeader(title, style, forceExpanded); |
| 336 title = ''; | 334 title = ''; |
| 337 } | 335 } |
| 338 | 336 |
| 339 if (flowEventsEnabled && (e.nextFlow || e.previousFlow)) | |
| 340 this._flowEventIndexByEvent.set(e, this._entryData.length); | |
| 341 var level = this._currentLevel + openEvents.length; | 337 var level = this._currentLevel + openEvents.length; |
| 342 this._appendEvent(e, level); | 338 if (flowEventsEnabled) |
| 339 this._appendFlowEvent(e, level); |
| 340 if (e.phase !== SDK.TracingModel.Phase.FlowEnd) |
| 341 this._appendEvent(e, level); |
| 343 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e)) | 342 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e)) |
| 344 this._timelineData.entryTotalTimes[this._entryData.length] = undefined; | 343 this._timelineData.entryTotalTimes[this._entryData.length] = undefined; |
| 345 | 344 |
| 346 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); | 345 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); |
| 347 if (e.endTime) | 346 if (e.endTime) |
| 348 openEvents.push(e); | 347 openEvents.push(e); |
| 349 } | 348 } |
| 350 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; | 349 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; |
| 351 this._entryTypeByLevel.fill(entryType, this._currentLevel); | 350 this._entryTypeByLevel.fill(entryType, this._currentLevel); |
| 352 this._currentLevel += maxStackDepth; | 351 this._currentLevel += maxStackDepth; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 var style = Timeline.TimelineUIUtils.markerStyleForFrame(); | 439 var style = Timeline.TimelineUIUtils.markerStyleForFrame(); |
| 441 this._entryTypeByLevel[this._currentLevel] = Timeline.TimelineFlameChartEntr
yType.Frame; | 440 this._entryTypeByLevel[this._currentLevel] = Timeline.TimelineFlameChartEntr
yType.Frame; |
| 442 for (var i = 0; i < frames.length; ++i) { | 441 for (var i = 0; i < frames.length; ++i) { |
| 443 this._markers.push(new Timeline.TimelineFlameChartMarker( | 442 this._markers.push(new Timeline.TimelineFlameChartMarker( |
| 444 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi
me(), style)); | 443 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi
me(), style)); |
| 445 this._appendFrame(frames[i]); | 444 this._appendFrame(frames[i]); |
| 446 } | 445 } |
| 447 ++this._currentLevel; | 446 ++this._currentLevel; |
| 448 } | 447 } |
| 449 | 448 |
| 450 _appendFlowData() { | |
| 451 var flowPairs = []; | |
| 452 for (var flowEvent of this._performanceModel.tracingModel().flowHeads()) { | |
| 453 var lastTime; | |
| 454 var lastLevel; | |
| 455 for (; flowEvent; flowEvent = flowEvent.nextFlow) { | |
| 456 var index = this._flowEventIndexByEvent.get(flowEvent); | |
| 457 if (typeof index !== 'number') | |
| 458 continue; | |
| 459 var level = this._timelineData.entryLevels[index]; | |
| 460 var time = flowEvent.startTime; | |
| 461 if (lastTime) | |
| 462 flowPairs.push({startTime: lastTime, startLevel: lastLevel, endTime: t
ime, endLevel: level}); | |
| 463 lastTime = time; | |
| 464 lastLevel = level; | |
| 465 } | |
| 466 } | |
| 467 flowPairs.sort((a, b) => a.startTime - b.startTime); | |
| 468 var td = this._timelineData; | |
| 469 for (var fp of flowPairs) { | |
| 470 td.flowStartTimes.push(fp.startTime); | |
| 471 td.flowStartLevels.push(fp.startLevel); | |
| 472 td.flowEndTimes.push(fp.endTime); | |
| 473 td.flowEndLevels.push(fp.endLevel); | |
| 474 } | |
| 475 } | |
| 476 /** | 449 /** |
| 477 * @param {number} entryIndex | 450 * @param {number} entryIndex |
| 478 * @return {!Timeline.TimelineFlameChartEntryType} | 451 * @return {!Timeline.TimelineFlameChartEntryType} |
| 479 */ | 452 */ |
| 480 _entryType(entryIndex) { | 453 _entryType(entryIndex) { |
| 481 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; | 454 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; |
| 482 } | 455 } |
| 483 | 456 |
| 484 /** | 457 /** |
| 485 * @override | 458 * @override |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 var index = this._entryData.length; | 728 var index = this._entryData.length; |
| 756 this._entryData.push(steps[i + eventOffset]); | 729 this._entryData.push(steps[i + eventOffset]); |
| 757 var startTime = steps[i].startTime; | 730 var startTime = steps[i].startTime; |
| 758 this._timelineData.entryLevels[index] = level; | 731 this._timelineData.entryLevels[index] = level; |
| 759 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start
Time; | 732 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start
Time; |
| 760 this._timelineData.entryStartTimes[index] = startTime; | 733 this._timelineData.entryStartTimes[index] = startTime; |
| 761 } | 734 } |
| 762 } | 735 } |
| 763 | 736 |
| 764 /** | 737 /** |
| 738 * @param {!SDK.TracingModel.Event} event |
| 739 * @param {number} level |
| 740 */ |
| 741 _appendFlowEvent(event, level) { |
| 742 var timelineData = this._timelineData; |
| 743 /** |
| 744 * @param {!SDK.TracingModel.Event} event |
| 745 * @return {number} |
| 746 */ |
| 747 function pushStartFlow(event) { |
| 748 var flowIndex = timelineData.flowStartTimes.length; |
| 749 timelineData.flowStartTimes.push(event.startTime); |
| 750 timelineData.flowStartLevels.push(level); |
| 751 return flowIndex; |
| 752 } |
| 753 |
| 754 /** |
| 755 * @param {!SDK.TracingModel.Event} event |
| 756 * @param {number} flowIndex |
| 757 */ |
| 758 function pushEndFlow(event, flowIndex) { |
| 759 timelineData.flowEndTimes[flowIndex] = event.startTime; |
| 760 timelineData.flowEndLevels[flowIndex] = level; |
| 761 } |
| 762 |
| 763 switch (event.phase) { |
| 764 case SDK.TracingModel.Phase.FlowBegin: |
| 765 this._flowEventIndexById.set(event.id, pushStartFlow(event)); |
| 766 break; |
| 767 case SDK.TracingModel.Phase.FlowStep: |
| 768 pushEndFlow(event, this._flowEventIndexById.get(event.id)); |
| 769 this._flowEventIndexById.set(event.id, pushStartFlow(event)); |
| 770 break; |
| 771 case SDK.TracingModel.Phase.FlowEnd: |
| 772 pushEndFlow(event, this._flowEventIndexById.get(event.id)); |
| 773 this._flowEventIndexById.delete(event.id); |
| 774 break; |
| 775 } |
| 776 } |
| 777 |
| 778 /** |
| 765 * @param {!TimelineModel.TimelineFrame} frame | 779 * @param {!TimelineModel.TimelineFrame} frame |
| 766 */ | 780 */ |
| 767 _appendFrame(frame) { | 781 _appendFrame(frame) { |
| 768 var index = this._entryData.length; | 782 var index = this._entryData.length; |
| 769 this._entryData.push(frame); | 783 this._entryData.push(frame); |
| 770 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true)
; | 784 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true)
; |
| 771 this._timelineData.entryLevels[index] = this._currentLevel; | 785 this._timelineData.entryLevels[index] = this._currentLevel; |
| 772 this._timelineData.entryTotalTimes[index] = frame.duration; | 786 this._timelineData.entryTotalTimes[index] = frame.duration; |
| 773 this._timelineData.entryStartTimes[index] = frame.startTime; | 787 this._timelineData.entryStartTimes[index] = frame.startTime; |
| 774 } | 788 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 * @return {boolean} | 869 * @return {boolean} |
| 856 */ | 870 */ |
| 857 _isVisible(event) { | 871 _isVisible(event) { |
| 858 return this._filters.every(function(filter) { | 872 return this._filters.every(function(filter) { |
| 859 return filter.accept(event); | 873 return filter.accept(event); |
| 860 }); | 874 }); |
| 861 } | 875 } |
| 862 }; | 876 }; |
| 863 | 877 |
| 864 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; | 878 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; |
| OLD | NEW |