Chromium Code Reviews| 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<string, number>} */ | 78 /** @type {!Map<!SDK.TracingModel.Event, number>} */ |
| 79 this._flowEventIndexById = new Map(); | 79 this._flowEventIndexByEvent = 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._flowEventIndexById.clear(); | 181 this._flowEventIndexByEvent.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 | |
| 235 for (let extensionIndex = 0; extensionIndex < this._extensionInfo.length; ex tensionIndex++) | 238 for (let extensionIndex = 0; extensionIndex < this._extensionInfo.length; ex tensionIndex++) |
| 236 this._innerAppendExtensionEvents(extensionIndex); | 239 this._innerAppendExtensionEvents(extensionIndex); |
| 237 | 240 |
| 238 /** | 241 /** |
| 239 * @param {!Timeline.TimelineFlameChartMarker} a | 242 * @param {!Timeline.TimelineFlameChartMarker} a |
| 240 * @param {!Timeline.TimelineFlameChartMarker} b | 243 * @param {!Timeline.TimelineFlameChartMarker} b |
| 241 */ | 244 */ |
| 242 function compareStartTime(a, b) { | 245 function compareStartTime(a, b) { |
| 243 return a.startTime() - b.startTime(); | 246 return a.startTime() - b.startTime(); |
| 244 } | 247 } |
| 245 | 248 |
| 246 this._markers.sort(compareStartTime); | 249 this._markers.sort(compareStartTime); |
| 247 this._timelineData.markers = this._markers; | 250 this._timelineData.markers = this._markers; |
| 248 this._flowEventIndexById.clear(); | |
| 249 | 251 |
| 250 return this._timelineData; | 252 return this._timelineData; |
| 251 } | 253 } |
| 252 | 254 |
| 253 /** | 255 /** |
| 254 * @override | 256 * @override |
| 255 * @return {number} | 257 * @return {number} |
| 256 */ | 258 */ |
| 257 minimumBoundary() { | 259 minimumBoundary() { |
| 258 return this._minimumBoundary; | 260 return this._minimumBoundary; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 var parent = openEvents.peekLast(); | 329 var parent = openEvents.peekLast(); |
| 328 if (parent && parent._blackboxRoot) | 330 if (parent && parent._blackboxRoot) |
| 329 continue; | 331 continue; |
| 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 |
| 339 if (flowEventsEnabled && (e.nextFlow || e.previousFlow)) | |
| 340 this._flowEventIndexByEvent.set(e, this._entryData.length); | |
| 337 var level = this._currentLevel + openEvents.length; | 341 var level = this._currentLevel + openEvents.length; |
| 338 if (flowEventsEnabled) | 342 this._appendEvent(e, level); |
| 339 this._appendFlowEvent(e, level); | |
| 340 if (e.phase !== SDK.TracingModel.Phase.FlowEnd) | |
| 341 this._appendEvent(e, level); | |
| 342 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e)) | 343 if (!isExtension && TimelineModel.TimelineModel.isMarkerEvent(e)) |
| 343 this._timelineData.entryTotalTimes[this._entryData.length] = undefined; | 344 this._timelineData.entryTotalTimes[this._entryData.length] = undefined; |
| 344 | 345 |
| 345 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); | 346 maxStackDepth = Math.max(maxStackDepth, openEvents.length + 1); |
| 346 if (e.endTime) | 347 if (e.endTime) |
| 347 openEvents.push(e); | 348 openEvents.push(e); |
| 348 } | 349 } |
| 349 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; | 350 this._entryTypeByLevel.length = this._currentLevel + maxStackDepth; |
| 350 this._entryTypeByLevel.fill(entryType, this._currentLevel); | 351 this._entryTypeByLevel.fill(entryType, this._currentLevel); |
| 351 this._currentLevel += maxStackDepth; | 352 this._currentLevel += maxStackDepth; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 var style = Timeline.TimelineUIUtils.markerStyleForFrame(); | 440 var style = Timeline.TimelineUIUtils.markerStyleForFrame(); |
| 440 this._entryTypeByLevel[this._currentLevel] = Timeline.TimelineFlameChartEntr yType.Frame; | 441 this._entryTypeByLevel[this._currentLevel] = Timeline.TimelineFlameChartEntr yType.Frame; |
| 441 for (var i = 0; i < frames.length; ++i) { | 442 for (var i = 0; i < frames.length; ++i) { |
| 442 this._markers.push(new Timeline.TimelineFlameChartMarker( | 443 this._markers.push(new Timeline.TimelineFlameChartMarker( |
| 443 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi me(), style)); | 444 frames[i].startTime, frames[i].startTime - this._model.minimumRecordTi me(), style)); |
| 444 this._appendFrame(frames[i]); | 445 this._appendFrame(frames[i]); |
| 445 } | 446 } |
| 446 ++this._currentLevel; | 447 ++this._currentLevel; |
| 447 } | 448 } |
| 448 | 449 |
| 450 _appendFlowData() { | |
| 451 var flowPairs = []; | |
| 452 for (var flowEvent of this._performanceModel.tracingModel().flowHeads()) { | |
| 453 var lastTime = undefined; | |
| 454 var lastLevel = undefined; | |
| 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); | |
|
pfeldman
2017/03/16 02:00:22
Sort again?!?
| |
| 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 } | |
| 449 /** | 476 /** |
| 450 * @param {number} entryIndex | 477 * @param {number} entryIndex |
| 451 * @return {!Timeline.TimelineFlameChartEntryType} | 478 * @return {!Timeline.TimelineFlameChartEntryType} |
| 452 */ | 479 */ |
| 453 _entryType(entryIndex) { | 480 _entryType(entryIndex) { |
| 454 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; | 481 return this._entryTypeByLevel[this._timelineData.entryLevels[entryIndex]]; |
| 455 } | 482 } |
| 456 | 483 |
| 457 /** | 484 /** |
| 458 * @override | 485 * @override |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 var index = this._entryData.length; | 755 var index = this._entryData.length; |
| 729 this._entryData.push(steps[i + eventOffset]); | 756 this._entryData.push(steps[i + eventOffset]); |
| 730 var startTime = steps[i].startTime; | 757 var startTime = steps[i].startTime; |
| 731 this._timelineData.entryLevels[index] = level; | 758 this._timelineData.entryLevels[index] = level; |
| 732 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start Time; | 759 this._timelineData.entryTotalTimes[index] = steps[i + 1].startTime - start Time; |
| 733 this._timelineData.entryStartTimes[index] = startTime; | 760 this._timelineData.entryStartTimes[index] = startTime; |
| 734 } | 761 } |
| 735 } | 762 } |
| 736 | 763 |
| 737 /** | 764 /** |
| 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 /** | |
| 779 * @param {!TimelineModel.TimelineFrame} frame | 765 * @param {!TimelineModel.TimelineFrame} frame |
| 780 */ | 766 */ |
| 781 _appendFrame(frame) { | 767 _appendFrame(frame) { |
| 782 var index = this._entryData.length; | 768 var index = this._entryData.length; |
| 783 this._entryData.push(frame); | 769 this._entryData.push(frame); |
| 784 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true) ; | 770 this._entryIndexToTitle[index] = Number.millisToString(frame.duration, true) ; |
| 785 this._timelineData.entryLevels[index] = this._currentLevel; | 771 this._timelineData.entryLevels[index] = this._currentLevel; |
| 786 this._timelineData.entryTotalTimes[index] = frame.duration; | 772 this._timelineData.entryTotalTimes[index] = frame.duration; |
| 787 this._timelineData.entryStartTimes[index] = frame.startTime; | 773 this._timelineData.entryStartTimes[index] = frame.startTime; |
| 788 } | 774 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 * @return {boolean} | 855 * @return {boolean} |
| 870 */ | 856 */ |
| 871 _isVisible(event) { | 857 _isVisible(event) { |
| 872 return this._filters.every(function(filter) { | 858 return this._filters.every(function(filter) { |
| 873 return filter.accept(event); | 859 return filter.accept(event); |
| 874 }); | 860 }); |
| 875 } | 861 } |
| 876 }; | 862 }; |
| 877 | 863 |
| 878 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; | 864 Timeline.TimelineFlameChartDataProvider.InstantEventVisibleDurationMs = 0.001; |
| OLD | NEW |