| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 }, | 156 }, |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * @param {string} headerName | 159 * @param {string} headerName |
| 160 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 160 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
| 161 */ | 161 */ |
| 162 _appendThreadTimelineData: function(headerName, events) | 162 _appendThreadTimelineData: function(headerName, events) |
| 163 { | 163 { |
| 164 var maxStackDepth = 0; | 164 var maxStackDepth = 0; |
| 165 var openEvents = []; | 165 var openEvents = []; |
| 166 var heights = []; | 166 var levels = []; |
| 167 var jsHeights = []; |
| 167 var headerAppended = false; | 168 var headerAppended = false; |
| 168 var level = 0; | 169 var level = 0; |
| 170 var jsStackHeight = 0; |
| 169 for (var i = 0; i < events.length; ++i) { | 171 for (var i = 0; i < events.length; ++i) { |
| 170 var e = events[i]; | 172 var e = events[i]; |
| 171 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan
t) | 173 if (!e.endTime && e.phase !== WebInspector.TracingModel.Phase.Instan
t) |
| 172 continue; | 174 continue; |
| 173 if (!this._isVisible(e)) | 175 if (!this._isVisible(e)) |
| 174 continue; | 176 continue; |
| 175 while (openEvents.length && openEvents.peekLast().endTime <= e.start
Time) { | 177 while (openEvents.length && openEvents.peekLast().endTime <= e.start
Time) { |
| 176 openEvents.pop(); | 178 openEvents.pop(); |
| 177 level = heights.pop(); | 179 level = levels.pop(); |
| 180 jsStackHeight = jsHeights.pop(); |
| 178 } | 181 } |
| 179 if (!headerAppended) { | 182 if (!headerAppended) { |
| 180 this._appendHeaderRecord(headerName, this._currentLevel); | 183 this._appendHeaderRecord(headerName, this._currentLevel); |
| 181 ++level; | 184 ++level; |
| 182 headerAppended = true; | 185 headerAppended = true; |
| 183 } | 186 } |
| 184 var height = this._processEvent(e, this._currentLevel + level); | 187 var jsHeightDelta = this._processEvent(e, this._currentLevel + level
, jsStackHeight); |
| 185 if (e.endTime) { | 188 if (e.endTime) { |
| 186 openEvents.push(e); | 189 openEvents.push(e); |
| 187 heights.push(level) | 190 jsHeights.push(jsStackHeight); |
| 191 levels.push(level); |
| 188 } | 192 } |
| 189 level += height; | 193 level += 1 + jsHeightDelta; |
| 194 jsStackHeight += jsHeightDelta; |
| 190 maxStackDepth = Math.max(maxStackDepth, level); | 195 maxStackDepth = Math.max(maxStackDepth, level); |
| 191 } | 196 } |
| 192 this._currentLevel += maxStackDepth; | 197 this._currentLevel += maxStackDepth; |
| 193 }, | 198 }, |
| 194 | 199 |
| 195 /** | 200 /** |
| 196 * @param {!WebInspector.TracingModel.Event} event | 201 * @param {!WebInspector.TracingModel.Event} event |
| 197 * @param {number} baseLevel | 202 * @param {number} level |
| 203 * @param {number} jsStackHeight |
| 198 * @return {number} | 204 * @return {number} |
| 199 */ | 205 */ |
| 200 _processEvent: function(event, baseLevel) | 206 _processEvent: function(event, level, jsStackHeight) |
| 201 { | 207 { |
| 202 var level = baseLevel; | 208 var jsHeightDelta = 0; |
| 203 if (event.stackTrace && WebInspector.experimentsSettings.timelineJSCPUPr
ofile.isEnabled()) { | 209 if (event.stackTrace && WebInspector.experimentsSettings.timelineJSCPUPr
ofile.isEnabled()) { |
| 204 for (var i = event.stackTrace.length - 1; i >= 0; --i) { | 210 for (var i = event.stackTrace.length - 1; i >= jsStackHeight; --i) { |
| 205 var payload = /** @type {!WebInspector.TracingModel.EventPayload
} */ ({ | 211 var payload = /** @type {!WebInspector.TracingModel.EventPayload
} */ ({ |
| 206 ph: WebInspector.TracingModel.Phase.Complete, | 212 ph: WebInspector.TracingModel.Phase.Complete, |
| 207 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory
, | 213 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory
, |
| 208 name: WebInspector.TracingTimelineModel.RecordType.JSFrame, | 214 name: WebInspector.TracingTimelineModel.RecordType.JSFrame, |
| 209 ts: event.startTime * 1000, | 215 ts: event.startTime * 1000, |
| 210 dur: event.duration * 1000, | 216 dur: event.duration * 1000, |
| 211 args: { | 217 args: { |
| 212 data: event.stackTrace[i] | 218 data: event.stackTrace[i] |
| 213 } | 219 } |
| 214 }); | 220 }); |
| 215 var jsFrameEvent = new WebInspector.TracingModel.Event(payload,
0, event.thread); | 221 var jsFrameEvent = new WebInspector.TracingModel.Event(payload,
0, event.thread); |
| 216 this._appendEvent(jsFrameEvent, level++); | 222 this._appendEvent(jsFrameEvent, level++); |
| 217 } | 223 } |
| 224 jsHeightDelta = event.stackTrace.length - jsStackHeight; |
| 218 } | 225 } |
| 219 this._appendEvent(event, level++) | 226 this._appendEvent(event, level) |
| 220 return level - baseLevel; | 227 return jsHeightDelta; |
| 221 }, | 228 }, |
| 222 | 229 |
| 223 /** | 230 /** |
| 224 * @param {!WebInspector.TracingTimelineModel.Filter} filter | 231 * @param {!WebInspector.TracingTimelineModel.Filter} filter |
| 225 */ | 232 */ |
| 226 addFilter: function(filter) | 233 addFilter: function(filter) |
| 227 { | 234 { |
| 228 this._filters.push(filter); | 235 this._filters.push(filter); |
| 229 }, | 236 }, |
| 230 | 237 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 /** | 627 /** |
| 621 * @constructor | 628 * @constructor |
| 622 * @param {!WebInspector.TimelineSelection} selection | 629 * @param {!WebInspector.TimelineSelection} selection |
| 623 * @param {number} entryIndex | 630 * @param {number} entryIndex |
| 624 */ | 631 */ |
| 625 WebInspector.TimelineFlameChart.Selection = function(selection, entryIndex) | 632 WebInspector.TimelineFlameChart.Selection = function(selection, entryIndex) |
| 626 { | 633 { |
| 627 this.timelineSelection = selection; | 634 this.timelineSelection = selection; |
| 628 this.entryIndex = entryIndex; | 635 this.entryIndex = entryIndex; |
| 629 } | 636 } |
| OLD | NEW |