| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 /** | 109 /** |
| 110 * @param {number} startTime | 110 * @param {number} startTime |
| 111 * @param {number} endTime | 111 * @param {number} endTime |
| 112 * @return {?Array.<number>} | 112 * @return {?Array.<number>} |
| 113 */ | 113 */ |
| 114 dividerOffsets: function(startTime, endTime) | 114 dividerOffsets: function(startTime, endTime) |
| 115 { | 115 { |
| 116 return null; | 116 return null; |
| 117 }, | 117 }, |
| 118 | 118 |
| 119 /** |
| 120 * @override |
| 121 * @param {number} index |
| 122 * @return {string} |
| 123 */ |
| 124 markerColor: function(index) |
| 125 { |
| 126 var event = this._markerEvents[index]; |
| 127 return WebInspector.TracingTimelineUIUtils.markerEventColor(event.name); |
| 128 }, |
| 129 |
| 130 /** |
| 131 * @override |
| 132 * @param {number} index |
| 133 * @return {string} |
| 134 */ |
| 135 markerTitle: function(index) |
| 136 { |
| 137 var event = this._markerEvents[index]; |
| 138 return WebInspector.TracingTimelineUIUtils.eventTitle(event, this._model
); |
| 139 }, |
| 140 |
| 119 reset: function() | 141 reset: function() |
| 120 { | 142 { |
| 121 this._timelineData = null; | 143 this._timelineData = null; |
| 122 /** @type {!Array.<!WebInspector.TracingModel.Event>} */ | 144 /** @type {!Array.<!WebInspector.TracingModel.Event>} */ |
| 123 this._entryEvents = []; | 145 this._entryEvents = []; |
| 124 this._entryIndexToTitle = {}; | 146 this._entryIndexToTitle = {}; |
| 147 this._markerEvents = []; |
| 125 }, | 148 }, |
| 126 | 149 |
| 127 /** | 150 /** |
| 128 * @return {!WebInspector.FlameChart.TimelineData} | 151 * @return {!WebInspector.FlameChart.TimelineData} |
| 129 */ | 152 */ |
| 130 timelineData: function() | 153 timelineData: function() |
| 131 { | 154 { |
| 132 if (this._timelineData) | 155 if (this._timelineData) |
| 133 return this._timelineData; | 156 return this._timelineData; |
| 134 | 157 |
| 135 /** | 158 this._timelineData = new WebInspector.FlameChart.TimelineData([], [], []
); |
| 136 * @type {?WebInspector.FlameChart.TimelineData} | |
| 137 */ | |
| 138 this._timelineData = { | |
| 139 entryLevels: [], | |
| 140 entryTotalTimes: [], | |
| 141 entryStartTimes: [] | |
| 142 }; | |
| 143 | 159 |
| 144 this._minimumBoundary = this._model.minimumRecordTime(); | 160 this._minimumBoundary = this._model.minimumRecordTime(); |
| 145 this._timeSpan = Math.max(this._model.maximumRecordTime() - this._minimu
mBoundary, 1000); | 161 this._timeSpan = Math.max(this._model.maximumRecordTime() - this._minimu
mBoundary, 1000); |
| 146 this._currentLevel = 0; | 162 this._currentLevel = 0; |
| 147 this._appendThreadTimelineData(WebInspector.UIString("Main Thread"), thi
s._model.mainThreadEvents()); | 163 this._appendThreadTimelineData(WebInspector.UIString("Main Thread"), thi
s._model.mainThreadEvents()); |
| 148 var threads = this._model.virtualThreads(); | 164 var threads = this._model.virtualThreads(); |
| 149 for (var threadName in threads) { | 165 for (var threadName in threads) { |
| 150 if (threadName !== WebInspector.TimelineModel.MainThreadName) | 166 if (threadName !== WebInspector.TimelineModel.MainThreadName) |
| 151 this._appendThreadTimelineData(threadName, threads[threadName]); | 167 this._appendThreadTimelineData(threadName, threads[threadName]); |
| 152 } | 168 } |
| 153 return this._timelineData; | 169 return this._timelineData; |
| 154 }, | 170 }, |
| 155 | 171 |
| 156 /** | 172 /** |
| 157 * @param {string} headerName | 173 * @param {string} headerName |
| 158 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 174 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
| 159 */ | 175 */ |
| 160 _appendThreadTimelineData: function(headerName, events) | 176 _appendThreadTimelineData: function(headerName, events) |
| 161 { | 177 { |
| 162 var maxStackDepth = 0; | 178 var maxStackDepth = 0; |
| 163 var openEvents = []; | 179 var openEvents = []; |
| 164 var levels = []; | 180 var levels = []; |
| 165 var jsHeights = []; | 181 var jsHeights = []; |
| 166 var headerAppended = false; | 182 var headerAppended = false; |
| 167 var level = 0; | 183 var level = 0; |
| 168 var jsStackHeight = 0; | 184 var jsStackHeight = 0; |
| 169 for (var i = 0; i < events.length; ++i) { | 185 for (var i = 0; i < events.length; ++i) { |
| 170 var e = events[i]; | 186 var e = events[i]; |
| 171 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan
t) | 187 // FIXME: clean up once phase name is unified between Blink and Chro
mium. |
| 188 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan
t && e.phase !== "I") |
| 172 continue; | 189 continue; |
| 190 if (WebInspector.TracingTimelineUIUtils.isMarkerEvent(e)) { |
| 191 this._markerEvents.push(e); |
| 192 this._timelineData.markerTimestamps.push(e.startTime); |
| 193 } |
| 173 if (!this._isVisible(e)) | 194 if (!this._isVisible(e)) |
| 174 continue; | 195 continue; |
| 175 while (openEvents.length && openEvents.peekLast().endTime <= e.start
Time) { | 196 while (openEvents.length && openEvents.peekLast().endTime <= e.start
Time) { |
| 176 openEvents.pop(); | 197 openEvents.pop(); |
| 177 level = levels.pop(); | 198 level = levels.pop(); |
| 178 jsStackHeight = jsHeights.pop(); | 199 jsStackHeight = jsHeights.pop(); |
| 179 } | 200 } |
| 180 if (!headerAppended) { | 201 if (!headerAppended) { |
| 181 this._appendHeaderRecord(headerName, this._currentLevel); | 202 this._appendHeaderRecord(headerName, this._currentLevel); |
| 182 ++level; | 203 ++level; |
| 183 headerAppended = true; | 204 headerAppended = true; |
| 184 } | 205 } |
| 185 var jsHeightDelta = this._processEvent(e, this._currentLevel + level
, jsStackHeight); | 206 var jsHeightDelta = this._processEvent(e, this._currentLevel + level
, jsStackHeight); |
| 207 maxStackDepth = Math.max(maxStackDepth, level + 1 + jsHeightDelta); |
| 186 if (e.endTime) { | 208 if (e.endTime) { |
| 187 openEvents.push(e); | 209 openEvents.push(e); |
| 188 jsHeights.push(jsStackHeight); | 210 jsHeights.push(jsStackHeight); |
| 189 levels.push(level); | 211 levels.push(level); |
| 212 level += 1 + jsHeightDelta; |
| 190 } | 213 } |
| 191 level += 1 + jsHeightDelta; | |
| 192 jsStackHeight += jsHeightDelta; | 214 jsStackHeight += jsHeightDelta; |
| 193 maxStackDepth = Math.max(maxStackDepth, level); | |
| 194 } | 215 } |
| 195 this._currentLevel += maxStackDepth; | 216 this._currentLevel += maxStackDepth; |
| 196 }, | 217 }, |
| 197 | 218 |
| 198 /** | 219 /** |
| 199 * @param {!WebInspector.TracingModel.Event} event | 220 * @param {!WebInspector.TracingModel.Event} event |
| 200 * @param {number} level | 221 * @param {number} level |
| 201 * @param {number} jsStackHeight | 222 * @param {number} jsStackHeight |
| 202 * @return {number} | 223 * @return {number} |
| 203 */ | 224 */ |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 /** | 646 /** |
| 626 * @constructor | 647 * @constructor |
| 627 * @param {!WebInspector.TimelineSelection} selection | 648 * @param {!WebInspector.TimelineSelection} selection |
| 628 * @param {number} entryIndex | 649 * @param {number} entryIndex |
| 629 */ | 650 */ |
| 630 WebInspector.TimelineFlameChart.Selection = function(selection, entryIndex) | 651 WebInspector.TimelineFlameChart.Selection = function(selection, entryIndex) |
| 631 { | 652 { |
| 632 this.timelineSelection = selection; | 653 this.timelineSelection = selection; |
| 633 this.entryIndex = entryIndex; | 654 this.entryIndex = entryIndex; |
| 634 } | 655 } |
| OLD | NEW |