Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 127 |
| 128 // Short events filter is disabled by default. | 128 // Short events filter is disabled by default. |
| 129 this._durationFilter = new WebInspector.TimelineIsLongFilter(); | 129 this._durationFilter = new WebInspector.TimelineIsLongFilter(); |
| 130 | 130 |
| 131 this._expandOffset = 15; | 131 this._expandOffset = 15; |
| 132 | 132 |
| 133 this._headerLineCount = 1; | 133 this._headerLineCount = 1; |
| 134 this._adjustHeaderHeight(); | 134 this._adjustHeaderHeight(); |
| 135 | 135 |
| 136 this._mainThreadTasks = /** @type {!Array.<{startTime: number, endTime: numb er}>} */ ([]); | 136 this._mainThreadTasks = /** @type {!Array.<{startTime: number, endTime: numb er}>} */ ([]); |
| 137 this._cpuBarsElement = this._timelineGrid.gridHeaderElement.createChild("div ", "timeline-cpu-bars"); | 137 this._gpuTasks = /** @type {!Array.<{startTime: number, endTime: number, pid : number}>} */ ([]); |
| 138 var utilizationStripsElement = this._timelineGrid.gridHeaderElement.createCh ild("div", "timeline-utilization-strips"); | |
| 139 this._cpuBarsElement = utilizationStripsElement.createChild("div", "timeline -utilization-strip"); | |
| 140 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) | |
| 141 this._gpuBarsElement = utilizationStripsElement.createChild("div", "time line-utilization-strip gpu"); | |
| 138 this._mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelineR uler.get(); | 142 this._mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelineR uler.get(); |
| 139 WebInspector.settings.showCpuOnTimelineRuler.addChangeListener(this._showCpu OnTimelineRulerChanged, this); | 143 WebInspector.settings.showCpuOnTimelineRuler.addChangeListener(this._showCpu OnTimelineRulerChanged, this); |
| 140 | 144 |
| 141 this._createFileSelector(); | 145 this._createFileSelector(); |
| 142 | 146 |
| 143 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded, this._onTimelineEventRecorded, this); | 147 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordAdded, this._onTimelineEventRecorded, this); |
| 144 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this); | 148 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this); |
| 145 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); | 149 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); |
| 146 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this); | 150 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this); |
| 147 | 151 |
| 148 this._registerShortcuts(); | 152 this._registerShortcuts(); |
| 149 | 153 |
| 150 this._allRecordsCount = 0; | 154 this._allRecordsCount = 0; |
| 151 | 155 |
| 152 this._presentationModel.addFilter(new WebInspector.TimelineWindowFilter(this ._overviewPane)); | 156 this._presentationModel.addFilter(new WebInspector.TimelineWindowFilter(this ._overviewPane)); |
| 153 this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()) ; | 157 this._presentationModel.addFilter(new WebInspector.TimelineCategoryFilter()) ; |
| 154 this._presentationModel.addFilter(this._durationFilter); | 158 this._presentationModel.addFilter(this._durationFilter); |
| 155 } | 159 } |
| 156 | 160 |
| 157 // Define row and header height, should be in sync with styles for timeline grap hs. | 161 // Define row and header height, should be in sync with styles for timeline grap hs. |
| 158 WebInspector.TimelinePanel.rowHeight = 18; | 162 WebInspector.TimelinePanel.rowHeight = 18; |
| 159 WebInspector.TimelinePanel.headerHeight = 19; | 163 WebInspector.TimelinePanel.headerHeight = 19; |
| 160 | 164 |
| 161 WebInspector.TimelinePanel.durationFilterPresetsMs = [0, 1, 15]; | 165 WebInspector.TimelinePanel.durationFilterPresetsMs = [0, 1, 15]; |
| 162 | 166 |
| 163 WebInspector.TimelinePanel.prototype = { | 167 WebInspector.TimelinePanel.prototype = { |
| 164 _showCpuOnTimelineRulerChanged: function() | 168 _showCpuOnTimelineRulerChanged: function() |
| 165 { | 169 { |
| 166 var mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelin eRuler.get(); | 170 var mainThreadMonitoringEnabled = WebInspector.settings.showCpuOnTimelin eRuler.get(); |
| 167 if (this._mainThreadMonitoringEnabled !== mainThreadMonitoringEnabled) { | 171 if (this._mainThreadMonitoringEnabled !== mainThreadMonitoringEnabled) { |
| 168 this._mainThreadMonitoringEnabled = mainThreadMonitoringEnabled; | 172 this._mainThreadMonitoringEnabled = mainThreadMonitoringEnabled; |
| 169 this._refreshMainThreadBars(); | 173 this._refreshAllUtilizationBars(); |
| 170 } | 174 } |
| 171 }, | 175 }, |
| 172 | 176 |
| 173 /** | 177 /** |
| 174 * @param {Event} event | 178 * @param {Event} event |
| 175 * @return {boolean} | 179 * @return {boolean} |
| 176 */ | 180 */ |
| 177 _startSplitterDragging: function(event) | 181 _startSplitterDragging: function(event) |
| 178 { | 182 { |
| 179 this._dragOffset = this.element.offsetHeight - this._timelineMemorySplit ter.offsetTop - 2 + event.pageY; | 183 this._dragOffset = this.element.offsetHeight - this._timelineMemorySplit ter.offsetTop - 2 + event.pageY; |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 */ | 649 */ |
| 646 _innerAddRecordToTimeline: function(record) | 650 _innerAddRecordToTimeline: function(record) |
| 647 { | 651 { |
| 648 if (record.type === WebInspector.TimelineModel.RecordType.Program) { | 652 if (record.type === WebInspector.TimelineModel.RecordType.Program) { |
| 649 this._mainThreadTasks.push({ | 653 this._mainThreadTasks.push({ |
| 650 startTime: WebInspector.TimelineModel.startTimeInSeconds(record) , | 654 startTime: WebInspector.TimelineModel.startTimeInSeconds(record) , |
| 651 endTime: WebInspector.TimelineModel.endTimeInSeconds(record) | 655 endTime: WebInspector.TimelineModel.endTimeInSeconds(record) |
| 652 }); | 656 }); |
| 653 } | 657 } |
| 654 | 658 |
| 659 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask) { | |
| 660 this._gpuTasks.push({ | |
| 661 startTime: WebInspector.TimelineModel.startTimeInSeconds(record) , | |
| 662 endTime: WebInspector.TimelineModel.endTimeInSeconds(record), | |
| 663 pid: record.data["ownerPid"], | |
| 664 name: record.data["name"] | |
| 665 }); | |
| 666 return WebInspector.TimelineModel.startTimeInSeconds(record) < this. _overviewPane.windowEndTime(); | |
| 667 } | |
| 668 | |
| 655 var records = this._presentationModel.addRecord(record); | 669 var records = this._presentationModel.addRecord(record); |
| 656 this._allRecordsCount += records.length; | 670 this._allRecordsCount += records.length; |
| 657 var hasVisibleRecords = false; | 671 var hasVisibleRecords = false; |
| 658 var presentationModel = this._presentationModel; | 672 var presentationModel = this._presentationModel; |
| 659 function checkVisible(record) | 673 function checkVisible(record) |
| 660 { | 674 { |
| 661 hasVisibleRecords |= presentationModel.isVisible(record); | 675 hasVisibleRecords |= presentationModel.isVisible(record); |
| 662 } | 676 } |
| 663 WebInspector.TimelinePresentationModel.forAllRecords(records, checkVisib le); | 677 WebInspector.TimelinePresentationModel.forAllRecords(records, checkVisib le); |
| 664 | 678 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 | 735 |
| 722 _resetPanel: function() | 736 _resetPanel: function() |
| 723 { | 737 { |
| 724 this._presentationModel.reset(); | 738 this._presentationModel.reset(); |
| 725 this._boundariesAreValid = false; | 739 this._boundariesAreValid = false; |
| 726 this._adjustScrollPosition(0); | 740 this._adjustScrollPosition(0); |
| 727 this._closeRecordDetails(); | 741 this._closeRecordDetails(); |
| 728 this._allRecordsCount = 0; | 742 this._allRecordsCount = 0; |
| 729 this._automaticallySizeWindow = true; | 743 this._automaticallySizeWindow = true; |
| 730 this._mainThreadTasks = []; | 744 this._mainThreadTasks = []; |
| 745 this._gpuTasks = []; | |
| 746 this._pidToHue = {}; | |
| 731 }, | 747 }, |
| 732 | 748 |
| 733 elementsToRestoreScrollPositionsFor: function() | 749 elementsToRestoreScrollPositionsFor: function() |
| 734 { | 750 { |
| 735 return [this._containerElement]; | 751 return [this._containerElement]; |
| 736 }, | 752 }, |
| 737 | 753 |
| 738 wasShown: function() | 754 wasShown: function() |
| 739 { | 755 { |
| 740 WebInspector.Panel.prototype.wasShown.call(this); | 756 WebInspector.Panel.prototype.wasShown.call(this); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 if (frames) { | 827 if (frames) { |
| 812 this._updateFrameStatistics(frames); | 828 this._updateFrameStatistics(frames); |
| 813 const maxFramesForFrameBars = 30; | 829 const maxFramesForFrameBars = 30; |
| 814 if (frames.length && frames.length < maxFramesForFrameBars) { | 830 if (frames.length && frames.length < maxFramesForFrameBars) { |
| 815 this._timelineGrid.removeDividers(); | 831 this._timelineGrid.removeDividers(); |
| 816 this._updateFrameBars(frames); | 832 this._updateFrameBars(frames); |
| 817 } else | 833 } else |
| 818 this._timelineGrid.updateDividers(this._calculator); | 834 this._timelineGrid.updateDividers(this._calculator); |
| 819 } else | 835 } else |
| 820 this._timelineGrid.updateDividers(this._calculator); | 836 this._timelineGrid.updateDividers(this._calculator); |
| 821 if (this._mainThreadMonitoringEnabled) | 837 this._refreshAllUtilizationBars(); |
| 822 this._refreshMainThreadBars(); | |
| 823 } | 838 } |
| 824 if (this._memoryStatistics.visible()) | 839 if (this._memoryStatistics.visible()) |
| 825 this._memoryStatistics.refresh(); | 840 this._memoryStatistics.refresh(); |
| 826 this._boundariesAreValid = true; | 841 this._boundariesAreValid = true; |
| 827 }, | 842 }, |
| 828 | 843 |
| 829 revealRecordAt: function(time) | 844 revealRecordAt: function(time) |
| 830 { | 845 { |
| 831 var recordToReveal; | 846 var recordToReveal; |
| 832 function findRecordToReveal(record) | 847 function findRecordToReveal(record) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 this._updateSearchHighlight(false, true); | 987 this._updateSearchHighlight(false, true); |
| 973 | 988 |
| 974 if (highlightedListRowElement) { | 989 if (highlightedListRowElement) { |
| 975 highlightedListRowElement.addStyleClass("highlighted-timeline-record "); | 990 highlightedListRowElement.addStyleClass("highlighted-timeline-record "); |
| 976 highlightedGraphRowElement.addStyleClass("highlighted-timeline-recor d"); | 991 highlightedGraphRowElement.addStyleClass("highlighted-timeline-recor d"); |
| 977 } | 992 } |
| 978 | 993 |
| 979 return recordsInWindow.length; | 994 return recordsInWindow.length; |
| 980 }, | 995 }, |
| 981 | 996 |
| 982 _refreshMainThreadBars: function() | 997 _refreshAllUtilizationBars: function() |
| 983 { | 998 { |
| 999 this._refreshUtilizationBars(WebInspector.UIString("CPU"), this._mainThr eadMonitoringEnabled ? this._mainThreadTasks : [], this._cpuBarsElement); | |
| 1000 if (WebInspector.experimentsSettings.gpuTimeline.isEnabled()) | |
| 1001 this._refreshUtilizationBars(WebInspector.UIString("GPU"), this._gpu Tasks, this._gpuBarsElement); | |
| 1002 }, | |
| 1003 | |
| 1004 /** | |
| 1005 * @param {string} name | |
| 1006 * @param {!Array.<{startTime: number, endTime: number, pid: number}>} tasks | |
| 1007 * @param {Element} container | |
|
caseq
2013/11/05 14:26:58
?Element I guess?
alph
2013/11/05 14:59:16
Done.
| |
| 1008 */ | |
| 1009 _refreshUtilizationBars: function(name, tasks, container) | |
| 1010 { | |
| 1011 if (!container) | |
| 1012 return; | |
| 1013 | |
| 984 const barOffset = 3; | 1014 const barOffset = 3; |
| 985 const minGap = 3; | 1015 const minGap = 3; |
| 986 | 1016 |
| 987 var minWidth = WebInspector.TimelineCalculator._minWidth; | 1017 var minWidth = WebInspector.TimelineCalculator._minWidth; |
| 988 var widthAdjustment = minWidth / 2; | 1018 var widthAdjustment = minWidth / 2; |
| 989 | 1019 |
| 990 var width = this._graphRowsElementWidth; | 1020 var width = this._graphRowsElementWidth; |
| 991 var boundarySpan = this._overviewPane.windowEndTime() - this._overviewPa ne.windowStartTime(); | 1021 var boundarySpan = this._overviewPane.windowEndTime() - this._overviewPa ne.windowStartTime(); |
| 992 var scale = boundarySpan / (width - minWidth - this._timelinePaddingLeft ); | 1022 var scale = boundarySpan / (width - minWidth - this._timelinePaddingLeft ); |
| 993 var startTime = this._overviewPane.windowStartTime() - this._timelinePad dingLeft * scale; | 1023 var startTime = this._overviewPane.windowStartTime() - this._timelinePad dingLeft * scale; |
| 994 var endTime = startTime + width * scale; | 1024 var endTime = startTime + width * scale; |
| 995 | 1025 |
| 996 var tasks = this._mainThreadMonitoringEnabled ? this._mainThreadTasks : []; | |
| 997 | |
| 998 /** | 1026 /** |
| 999 * @param {number} value | 1027 * @param {number} value |
| 1000 * @param {{startTime: number, endTime: number}} task | 1028 * @param {{startTime: number, endTime: number}} task |
| 1001 * @return {number} | 1029 * @return {number} |
| 1002 */ | 1030 */ |
| 1003 function compareEndTime(value, task) | 1031 function compareEndTime(value, task) |
| 1004 { | 1032 { |
| 1005 return value < task.endTime ? -1 : 1; | 1033 return value < task.endTime ? -1 : 1; |
| 1006 } | 1034 } |
| 1007 | 1035 |
| 1008 var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime, tasks, compareEndTime); | 1036 var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime, tasks, compareEndTime); |
| 1009 | 1037 |
| 1010 var container = this._cpuBarsElement; | |
| 1011 var element = container.firstChild; | 1038 var element = container.firstChild; |
| 1012 var lastElement; | 1039 var lastElement; |
| 1013 var lastLeft; | 1040 var lastLeft; |
| 1014 var lastRight; | 1041 var lastRight; |
| 1015 | 1042 |
| 1043 if (!this._pidToHue) | |
| 1044 this._pidToHue = {}; | |
| 1045 var pidToHue = this._pidToHue; | |
| 1046 | |
| 1016 for (; taskIndex < tasks.length; ++taskIndex) { | 1047 for (; taskIndex < tasks.length; ++taskIndex) { |
| 1017 var task = tasks[taskIndex]; | 1048 var task = tasks[taskIndex]; |
| 1018 if (task.startTime > endTime) | 1049 if (task.startTime > endTime) |
| 1019 break; | 1050 break; |
| 1020 | 1051 |
| 1021 var left = Math.max(0, this._calculator.computePosition(task.startTi me) + barOffset - widthAdjustment); | 1052 var left = Math.max(0, this._calculator.computePosition(task.startTi me) + barOffset - widthAdjustment); |
| 1022 var right = Math.min(width, this._calculator.computePosition(task.en dTime) + barOffset + widthAdjustment); | 1053 var right = Math.min(width, this._calculator.computePosition(task.en dTime) + barOffset + widthAdjustment); |
| 1023 | 1054 |
| 1024 if (lastElement) { | 1055 if (lastElement) { |
| 1025 var gap = Math.floor(left) - Math.ceil(lastRight); | 1056 var gap = Math.floor(left) - Math.ceil(lastRight); |
| 1026 if (gap < minGap) { | 1057 if (gap < minGap |
| 1058 && (!task.pid || tasks[lastElement._tasksInfo.firstTaskIndex ].pid === task.pid)) { | |
| 1027 lastRight = right; | 1059 lastRight = right; |
| 1028 lastElement._tasksInfo.lastTaskIndex = taskIndex; | 1060 lastElement._tasksInfo.lastTaskIndex = taskIndex; |
| 1029 continue; | 1061 continue; |
| 1030 } | 1062 } |
| 1031 lastElement.style.width = (lastRight - lastLeft) + "px"; | 1063 lastElement.style.width = (lastRight - lastLeft) + "px"; |
| 1032 } | 1064 } |
| 1033 | 1065 |
| 1034 if (!element) | 1066 if (!element) |
| 1035 element = container.createChild("div", "timeline-graph-bar"); | 1067 element = container.createChild("div", "timeline-graph-bar"); |
| 1036 | 1068 |
| 1069 if (task.pid) { | |
| 1070 if (!(task.pid in pidToHue)) | |
| 1071 pidToHue[task.pid] = (Object.keys(pidToHue).length * 113) % 360; | |
| 1072 var hue = pidToHue[task.pid]; | |
| 1073 element.style.backgroundColor = "hsla(" + hue + ",50%,50%,0.2)"; | |
| 1074 } | |
| 1037 element.style.left = left + "px"; | 1075 element.style.left = left + "px"; |
| 1038 element._tasksInfo = {tasks: tasks, firstTaskIndex: taskIndex, lastT askIndex: taskIndex}; | 1076 element._tasksInfo = {name: name, tasks: tasks, firstTaskIndex: task Index, lastTaskIndex: taskIndex}; |
| 1039 lastLeft = left; | 1077 lastLeft = left; |
| 1040 lastRight = right; | 1078 lastRight = right; |
| 1041 | 1079 |
| 1042 lastElement = element; | 1080 lastElement = element; |
| 1043 element = element.nextSibling; | 1081 element = element.nextSibling; |
| 1044 } | 1082 } |
| 1045 | 1083 |
| 1046 if (lastElement) | 1084 if (lastElement) |
| 1047 lastElement.style.width = (lastRight - lastLeft) + "px"; | 1085 lastElement.style.width = (lastRight - lastLeft) + "px"; |
| 1048 | 1086 |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 | 1655 |
| 1618 /** | 1656 /** |
| 1619 * @param {!WebInspector.TimelinePresentationModel.Record} record | 1657 * @param {!WebInspector.TimelinePresentationModel.Record} record |
| 1620 * @return {boolean} | 1658 * @return {boolean} |
| 1621 */ | 1659 */ |
| 1622 accept: function(record) | 1660 accept: function(record) |
| 1623 { | 1661 { |
| 1624 return WebInspector.TimelineRecordListRow.testContentMatching(record, th is._regExp); | 1662 return WebInspector.TimelineRecordListRow.testContentMatching(record, th is._regExp); |
| 1625 } | 1663 } |
| 1626 } | 1664 } |
| OLD | NEW |