| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.TargetAwareObject} |
| 34 * @param {!WebInspector.TimelineModel} model | 34 * @param {!WebInspector.Target} target |
| 35 */ | 35 */ |
| 36 WebInspector.TimelineFrameModel = function(model) | 36 WebInspector.TimelineFrameModel = function(target) |
| 37 { | 37 { |
| 38 this._model = model; | 38 WebInspector.TargetAwareObject.call(this, target); |
| 39 | 39 |
| 40 this.reset(); | 40 this.reset(); |
| 41 var records = model.records(); | |
| 42 for (var i = 0; i < records.length; ++i) | |
| 43 this.addRecord(records[i]); | |
| 44 } | 41 } |
| 45 | 42 |
| 46 WebInspector.TimelineFrameModel.Events = { | 43 WebInspector.TimelineFrameModel.Events = { |
| 47 FrameAdded: "FrameAdded" | 44 FrameAdded: "FrameAdded" |
| 48 } | 45 } |
| 49 | 46 |
| 50 WebInspector.TimelineFrameModel._mainFrameMarkers = [ | 47 WebInspector.TimelineFrameModel._mainFrameMarkers = [ |
| 51 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, | 48 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, |
| 52 WebInspector.TimelineModel.RecordType.InvalidateLayout, | 49 WebInspector.TimelineModel.RecordType.InvalidateLayout, |
| 53 WebInspector.TimelineModel.RecordType.BeginFrame, | 50 WebInspector.TimelineModel.RecordType.BeginFrame, |
| 54 WebInspector.TimelineModel.RecordType.ScrollLayer | 51 WebInspector.TimelineModel.RecordType.ScrollLayer |
| 55 ]; | 52 ]; |
| 56 | 53 |
| 57 WebInspector.TimelineFrameModel.prototype = { | 54 WebInspector.TimelineFrameModel.prototype = { |
| 58 /** | 55 /** |
| 59 * @return {!WebInspector.Target} | |
| 60 */ | |
| 61 target: function() | |
| 62 { | |
| 63 return this._model.target(); | |
| 64 }, | |
| 65 | |
| 66 /** | |
| 67 * @return {!Array.<!WebInspector.TimelineFrame>} | 56 * @return {!Array.<!WebInspector.TimelineFrame>} |
| 68 */ | 57 */ |
| 69 frames: function() | 58 frames: function() |
| 70 { | 59 { |
| 71 return this._frames; | 60 return this._frames; |
| 72 }, | 61 }, |
| 73 | 62 |
| 74 /** | 63 /** |
| 75 * @param {number} startTime | 64 * @param {number} startTime |
| 76 * @param {number} endTime | 65 * @param {number} endTime |
| (...skipping 18 matching lines...) Expand all Loading... |
| 95 function compareEndTime(value, object) | 84 function compareEndTime(value, object) |
| 96 { | 85 { |
| 97 return value - object.endTime; | 86 return value - object.endTime; |
| 98 } | 87 } |
| 99 var frames = this._frames; | 88 var frames = this._frames; |
| 100 var firstFrame = insertionIndexForObjectInListSortedByFunction(startTime
, frames, compareEndTime); | 89 var firstFrame = insertionIndexForObjectInListSortedByFunction(startTime
, frames, compareEndTime); |
| 101 var lastFrame = insertionIndexForObjectInListSortedByFunction(endTime, f
rames, compareStartTime); | 90 var lastFrame = insertionIndexForObjectInListSortedByFunction(endTime, f
rames, compareStartTime); |
| 102 return frames.slice(firstFrame, lastFrame); | 91 return frames.slice(firstFrame, lastFrame); |
| 103 }, | 92 }, |
| 104 | 93 |
| 94 /** |
| 95 * @param {boolean} value |
| 96 */ |
| 97 setMergeRecords: function(value) |
| 98 { |
| 99 this._mergeRecords = value; |
| 100 }, |
| 101 |
| 105 reset: function() | 102 reset: function() |
| 106 { | 103 { |
| 104 this._mergeRecords = true; |
| 105 this._minimumRecordTime = Infinity; |
| 107 this._frames = []; | 106 this._frames = []; |
| 108 this._lastFrame = null; | 107 this._lastFrame = null; |
| 109 this._lastLayerTree = null; | 108 this._lastLayerTree = null; |
| 110 this._hasThreadedCompositing = false; | 109 this._hasThreadedCompositing = false; |
| 111 this._mainFrameCommitted = false; | 110 this._mainFrameCommitted = false; |
| 112 this._mainFrameRequested = false; | 111 this._mainFrameRequested = false; |
| 113 this._aggregatedMainThreadWork = null; | 112 this._aggregatedMainThreadWork = null; |
| 114 this._mergingBuffer = new WebInspector.TimelineMergingRecordBuffer(); | 113 this._mergingBuffer = new WebInspector.TimelineMergingRecordBuffer(); |
| 115 }, | 114 }, |
| 116 | 115 |
| 117 /** | 116 /** |
| 117 * @param {!Array.<!WebInspector.TimelineModel.Record>} records |
| 118 */ |
| 119 addRecords: function(records) |
| 120 { |
| 121 if (!records.length) |
| 122 return; |
| 123 if (records[0].startTime() < this._minimumRecordTime) |
| 124 this._minimumRecordTime = records[0].startTime(); |
| 125 for (var i = 0; i < records.length; ++i) |
| 126 this.addRecord(records[i]); |
| 127 }, |
| 128 |
| 129 /** |
| 118 * @param {!WebInspector.TimelineModel.Record} record | 130 * @param {!WebInspector.TimelineModel.Record} record |
| 119 */ | 131 */ |
| 120 addRecord: function(record) | 132 addRecord: function(record) |
| 121 { | 133 { |
| 122 var recordTypes = WebInspector.TimelineModel.RecordType; | 134 var recordTypes = WebInspector.TimelineModel.RecordType; |
| 123 var programRecord = record.type() === recordTypes.Program ? record : nul
l; | 135 var programRecord = record.type() === recordTypes.Program ? record : nul
l; |
| 124 | 136 |
| 125 // Start collecting main frame | 137 // Start collecting main frame |
| 126 if (programRecord) { | 138 if (programRecord) { |
| 127 if (!this._aggregatedMainThreadWork && this._findRecordRecursively(W
ebInspector.TimelineFrameModel._mainFrameMarkers, programRecord)) | 139 if (!this._aggregatedMainThreadWork && this._findRecordRecursively(W
ebInspector.TimelineFrameModel._mainFrameMarkers, programRecord)) |
| 128 this._aggregatedMainThreadWork = {}; | 140 this._aggregatedMainThreadWork = {}; |
| 129 } | 141 } |
| 130 /** type {Array.<!WebInspector.TimelineModel.Record>} */ | 142 /** type {Array.<!WebInspector.TimelineModel.Record>} */ |
| 131 var records = []; | 143 var records = []; |
| 132 if (this._model.bufferEvents()) | 144 if (!this._mergeRecords) |
| 133 records = [record]; | 145 records = [record]; |
| 134 else | 146 else |
| 135 records = this._mergingBuffer.process(record.thread(), /** type {Arr
ay.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() ||
[] : [record])); | 147 records = this._mergingBuffer.process(record.thread(), /** type {Arr
ay.<!WebInspector.TimelineModel.Record>} */(programRecord ? record.children() ||
[] : [record])); |
| 136 for (var i = 0; i < records.length; ++i) { | 148 for (var i = 0; i < records.length; ++i) { |
| 137 if (records[i].thread()) | 149 if (records[i].thread()) |
| 138 this._addBackgroundRecord(records[i]); | 150 this._addBackgroundRecord(records[i]); |
| 139 else | 151 else |
| 140 this._addMainThreadRecord(programRecord, records[i]); | 152 this._addMainThreadRecord(programRecord, records[i]); |
| 141 } | 153 } |
| 142 }, | 154 }, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 */ | 333 */ |
| 322 _startBackgroundFrame: function(startTime) | 334 _startBackgroundFrame: function(startTime) |
| 323 { | 335 { |
| 324 if (!this._hasThreadedCompositing) { | 336 if (!this._hasThreadedCompositing) { |
| 325 this._lastFrame = null; | 337 this._lastFrame = null; |
| 326 this._hasThreadedCompositing = true; | 338 this._hasThreadedCompositing = true; |
| 327 } | 339 } |
| 328 if (this._lastFrame) | 340 if (this._lastFrame) |
| 329 this._flushFrame(this._lastFrame, startTime); | 341 this._flushFrame(this._lastFrame, startTime); |
| 330 | 342 |
| 331 this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime -
this._model.minimumRecordTime()); | 343 this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime -
this._minimumRecordTime); |
| 332 }, | 344 }, |
| 333 | 345 |
| 334 /** | 346 /** |
| 335 * @param {number} startTime | 347 * @param {number} startTime |
| 336 */ | 348 */ |
| 337 _startMainThreadFrame: function(startTime) | 349 _startMainThreadFrame: function(startTime) |
| 338 { | 350 { |
| 339 if (this._lastFrame) | 351 if (this._lastFrame) |
| 340 this._flushFrame(this._lastFrame, startTime); | 352 this._flushFrame(this._lastFrame, startTime); |
| 341 this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime -
this._model.minimumRecordTime()); | 353 this._lastFrame = new WebInspector.TimelineFrame(startTime, startTime -
this._minimumRecordTime); |
| 342 }, | 354 }, |
| 343 | 355 |
| 344 /** | 356 /** |
| 345 * @param {!WebInspector.TimelineFrame} frame | 357 * @param {!WebInspector.TimelineFrame} frame |
| 346 * @param {number} endTime | 358 * @param {number} endTime |
| 347 */ | 359 */ |
| 348 _flushFrame: function(frame, endTime) | 360 _flushFrame: function(frame, endTime) |
| 349 { | 361 { |
| 350 frame._setLayerTree(this._lastLayerTree); | 362 frame._setLayerTree(this._lastLayerTree); |
| 351 frame._setEndTime(endTime); | 363 frame._setEndTime(endTime); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 365 if (!record.children()) | 377 if (!record.children()) |
| 366 return null; | 378 return null; |
| 367 for (var i = 0; i < record.children().length; ++i) { | 379 for (var i = 0; i < record.children().length; ++i) { |
| 368 var result = this._findRecordRecursively(types, record.children()[i]
); | 380 var result = this._findRecordRecursively(types, record.children()[i]
); |
| 369 if (result) | 381 if (result) |
| 370 return result; | 382 return result; |
| 371 } | 383 } |
| 372 return null; | 384 return null; |
| 373 }, | 385 }, |
| 374 | 386 |
| 375 __proto__: WebInspector.Object.prototype | 387 __proto__: WebInspector.TargetAwareObject.prototype |
| 376 } | 388 } |
| 377 | 389 |
| 378 /** | 390 /** |
| 379 * @constructor | 391 * @constructor |
| 380 * @param {!Array.<!WebInspector.TimelineFrame>} frames | 392 * @param {!Array.<!WebInspector.TimelineFrame>} frames |
| 381 */ | 393 */ |
| 382 WebInspector.FrameStatistics = function(frames) | 394 WebInspector.FrameStatistics = function(frames) |
| 383 { | 395 { |
| 384 this.frameCount = frames.length; | 396 this.frameCount = frames.length; |
| 385 this.minDuration = Infinity; | 397 this.minDuration = Infinity; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 this._updateCpuTime(); | 471 this._updateCpuTime(); |
| 460 }, | 472 }, |
| 461 | 473 |
| 462 _updateCpuTime: function() | 474 _updateCpuTime: function() |
| 463 { | 475 { |
| 464 this.cpuTime = 0; | 476 this.cpuTime = 0; |
| 465 for (var key in this.timeByCategory) | 477 for (var key in this.timeByCategory) |
| 466 this.cpuTime += this.timeByCategory[key]; | 478 this.cpuTime += this.timeByCategory[key]; |
| 467 } | 479 } |
| 468 } | 480 } |
| OLD | NEW |