Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.TracingModel} tracingModel | 7 * @param {!WebInspector.TracingModel} tracingModel |
| 8 * @param {!WebInspector.TimelineModel.Filter} recordFilter | 8 * @param {!WebInspector.TimelineModel.Filter} recordFilter |
| 9 * @extends {WebInspector.TimelineModel} | 9 * @extends {WebInspector.TimelineModel} |
| 10 */ | 10 */ |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 172 |
| 173 var endTime = Infinity; | 173 var endTime = Infinity; |
| 174 if (i + 1 < length) | 174 if (i + 1 < length) |
| 175 endTime = events[i + 1].startTime; | 175 endTime = events[i + 1].startTime; |
| 176 | 176 |
| 177 process.sortedThreads().forEach(this._processThreadEvents.bind(this, startTime, endTime, event.thread)); | 177 process.sortedThreads().forEach(this._processThreadEvents.bind(this, startTime, endTime, event.thread)); |
| 178 } | 178 } |
| 179 this._resetProcessingState(); | 179 this._resetProcessingState(); |
| 180 | 180 |
| 181 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | 181 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); |
| 182 if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled()) | |
| 183 this._injectJSFrameEvents(); | |
| 182 | 184 |
| 183 this._buildTimelineRecords(); | 185 this._buildTimelineRecords(); |
| 184 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 186 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
| 185 }, | 187 }, |
| 186 | 188 |
| 187 /** | 189 /** |
| 188 * @return {number} | 190 * @return {number} |
| 189 */ | 191 */ |
| 190 minimumRecordTime: function() | 192 minimumRecordTime: function() |
| 191 { | 193 { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 210 | 212 |
| 211 /** | 213 /** |
| 212 * @return {!Array.<!WebInspector.TracingModel.Event>} | 214 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 213 */ | 215 */ |
| 214 mainThreadEvents: function() | 216 mainThreadEvents: function() |
| 215 { | 217 { |
| 216 return this._virtualThreads[WebInspector.TimelineModel.MainThreadName] | | []; | 218 return this._virtualThreads[WebInspector.TimelineModel.MainThreadName] | | []; |
| 217 }, | 219 }, |
| 218 | 220 |
| 219 /** | 221 /** |
| 222 * @param {!Array.<!WebInspector.TracingModel.Event>} events | |
| 223 */ | |
| 224 _setMainThreadEvents: function(events) | |
| 225 { | |
| 226 return this._virtualThreads[WebInspector.TimelineModel.MainThreadName] = events; | |
| 227 }, | |
| 228 | |
| 229 /** | |
| 220 * @return {!Object.<string, !Array.<!WebInspector.TracingModel.Event>>} | 230 * @return {!Object.<string, !Array.<!WebInspector.TracingModel.Event>>} |
| 221 */ | 231 */ |
| 222 virtualThreads: function() | 232 virtualThreads: function() |
| 223 { | 233 { |
| 224 return this._virtualThreads; | 234 return this._virtualThreads; |
| 225 }, | 235 }, |
| 226 | 236 |
| 227 reset: function() | 237 reset: function() |
| 228 { | 238 { |
| 229 this._virtualThreads = {}; | 239 this._virtualThreads = {}; |
| 230 this._inspectedTargetEvents = []; | 240 this._inspectedTargetEvents = []; |
| 231 WebInspector.TimelineModel.prototype.reset.call(this); | 241 WebInspector.TimelineModel.prototype.reset.call(this); |
| 232 }, | 242 }, |
| 233 | 243 |
| 244 _injectJSFrameEvents: function() | |
| 245 { | |
| 246 var jsFrameEvents = []; | |
| 247 var mainThreadEvents = this.mainThreadEvents(); | |
| 248 for (var i = 0; i < mainThreadEvents.length; ++i) { | |
| 249 var event = mainThreadEvents[i]; | |
| 250 if (!event.stackTrace) | |
| 251 continue; | |
| 252 for (var j = event.stackTrace.length - 1; j >= 0; --j) { | |
| 253 var payload = /** @type {!WebInspector.TracingModel.EventPayload } */ ({ | |
| 254 ph: WebInspector.TracingModel.Phase.Complete, | |
| 255 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory , | |
| 256 name: WebInspector.TracingTimelineModel.RecordType.JSFrame, | |
|
yurys
2014/07/17 14:32:40
I'd rather add this on the flame chart directly wi
alph
2014/07/17 15:48:43
Done.
| |
| 257 ts: event.startTime * 1000, | |
| 258 dur: event.duration * 1000, | |
| 259 args: { | |
| 260 data: event.stackTrace[j] | |
| 261 } | |
| 262 }); | |
| 263 var jsFrameEvent = new WebInspector.TracingModel.Event(payload, 0, event.thread); | |
| 264 jsFrameEvents.push(jsFrameEvent); | |
| 265 } | |
| 266 } | |
| 267 this._setMainThreadEvents(jsFrameEvents.mergeOrdered(mainThreadEvents, W ebInspector.TracingModel.Event.orderedCompareStartTime)); | |
| 268 this._inspectedTargetEvents = jsFrameEvents.mergeOrdered(this._inspected TargetEvents, WebInspector.TracingModel.Event.orderedCompareStartTime); | |
| 269 }, | |
| 270 | |
| 234 _buildTimelineRecords: function() | 271 _buildTimelineRecords: function() |
| 235 { | 272 { |
| 236 var recordStack = []; | 273 var recordStack = []; |
| 237 var mainThreadEvents = this.mainThreadEvents(); | 274 var mainThreadEvents = this.mainThreadEvents(); |
| 238 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { | 275 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { |
| 239 var event = mainThreadEvents[i]; | 276 var event = mainThreadEvents[i]; |
| 240 while (recordStack.length) { | 277 while (recordStack.length) { |
| 241 var top = recordStack.peekLast(); | 278 var top = recordStack.peekLast(); |
| 242 if (top._event.endTime >= event.startTime) | 279 if (top._event.endTime >= event.startTime) |
| 243 break; | 280 break; |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 761 }, | 798 }, |
| 762 | 799 |
| 763 /** | 800 /** |
| 764 * @return {!WebInspector.TimelineModel} | 801 * @return {!WebInspector.TimelineModel} |
| 765 */ | 802 */ |
| 766 timelineModel: function() | 803 timelineModel: function() |
| 767 { | 804 { |
| 768 return this._model; | 805 return this._model; |
| 769 } | 806 } |
| 770 } | 807 } |
| OLD | NEW |