| 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 13 matching lines...) Expand all Loading... |
| 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 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.TimelineEventOverview = class extends WebInspector.TimelineOverview
Base { | 34 Timeline.TimelineEventOverview = class extends UI.TimelineOverviewBase { |
| 35 /** | 35 /** |
| 36 * @param {string} id | 36 * @param {string} id |
| 37 * @param {?string} title | 37 * @param {?string} title |
| 38 * @param {!WebInspector.TimelineModel} model | 38 * @param {!TimelineModel.TimelineModel} model |
| 39 */ | 39 */ |
| 40 constructor(id, title, model) { | 40 constructor(id, title, model) { |
| 41 super(); | 41 super(); |
| 42 this.element.id = 'timeline-overview-' + id; | 42 this.element.id = 'timeline-overview-' + id; |
| 43 this.element.classList.add('overview-strip'); | 43 this.element.classList.add('overview-strip'); |
| 44 if (title) | 44 if (title) |
| 45 this.element.createChild('div', 'timeline-overview-strip-title').textConte
nt = title; | 45 this.element.createChild('div', 'timeline-overview-strip-title').textConte
nt = title; |
| 46 this._model = model; | 46 this._model = model; |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 return { | 85 return { |
| 86 left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / time
Span, 1) : 0, | 86 left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / time
Span, 1) : 0, |
| 87 right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeS
pan : 1 | 87 right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeS
pan : 1 |
| 88 }; | 88 }; |
| 89 } | 89 } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * @unrestricted | 93 * @unrestricted |
| 94 */ | 94 */ |
| 95 WebInspector.TimelineEventOverviewInput = class extends WebInspector.TimelineEve
ntOverview { | 95 Timeline.TimelineEventOverviewInput = class extends Timeline.TimelineEventOvervi
ew { |
| 96 /** | 96 /** |
| 97 * @param {!WebInspector.TimelineModel} model | 97 * @param {!TimelineModel.TimelineModel} model |
| 98 */ | 98 */ |
| 99 constructor(model) { | 99 constructor(model) { |
| 100 super('input', null, model); | 100 super('input', null, model); |
| 101 } | 101 } |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * @override | 104 * @override |
| 105 */ | 105 */ |
| 106 update() { | 106 update() { |
| 107 super.update(); | 107 super.update(); |
| 108 var events = this._model.mainThreadEvents(); | 108 var events = this._model.mainThreadEvents(); |
| 109 var height = this._canvas.height; | 109 var height = this._canvas.height; |
| 110 var descriptors = WebInspector.TimelineUIUtils.eventDispatchDesciptors(); | 110 var descriptors = Timeline.TimelineUIUtils.eventDispatchDesciptors(); |
| 111 /** @type {!Map.<string,!WebInspector.TimelineUIUtils.EventDispatchTypeDescr
iptor>} */ | 111 /** @type {!Map.<string,!Timeline.TimelineUIUtils.EventDispatchTypeDescripto
r>} */ |
| 112 var descriptorsByType = new Map(); | 112 var descriptorsByType = new Map(); |
| 113 var maxPriority = -1; | 113 var maxPriority = -1; |
| 114 for (var descriptor of descriptors) { | 114 for (var descriptor of descriptors) { |
| 115 for (var type of descriptor.eventTypes) | 115 for (var type of descriptor.eventTypes) |
| 116 descriptorsByType.set(type, descriptor); | 116 descriptorsByType.set(type, descriptor); |
| 117 maxPriority = Math.max(maxPriority, descriptor.priority); | 117 maxPriority = Math.max(maxPriority, descriptor.priority); |
| 118 } | 118 } |
| 119 | 119 |
| 120 var /** @const */ minWidth = 2 * window.devicePixelRatio; | 120 var /** @const */ minWidth = 2 * window.devicePixelRatio; |
| 121 var timeOffset = this._model.minimumRecordTime(); | 121 var timeOffset = this._model.minimumRecordTime(); |
| 122 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 122 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 123 var canvasWidth = this._canvas.width; | 123 var canvasWidth = this._canvas.width; |
| 124 var scale = canvasWidth / timeSpan; | 124 var scale = canvasWidth / timeSpan; |
| 125 | 125 |
| 126 for (var priority = 0; priority <= maxPriority; ++priority) { | 126 for (var priority = 0; priority <= maxPriority; ++priority) { |
| 127 for (var i = 0; i < events.length; ++i) { | 127 for (var i = 0; i < events.length; ++i) { |
| 128 var event = events[i]; | 128 var event = events[i]; |
| 129 if (event.name !== WebInspector.TimelineModel.RecordType.EventDispatch) | 129 if (event.name !== TimelineModel.TimelineModel.RecordType.EventDispatch) |
| 130 continue; | 130 continue; |
| 131 var descriptor = descriptorsByType.get(event.args['data']['type']); | 131 var descriptor = descriptorsByType.get(event.args['data']['type']); |
| 132 if (!descriptor || descriptor.priority !== priority) | 132 if (!descriptor || descriptor.priority !== priority) |
| 133 continue; | 133 continue; |
| 134 var start = Number.constrain(Math.floor((event.startTime - timeOffset) *
scale), 0, canvasWidth); | 134 var start = Number.constrain(Math.floor((event.startTime - timeOffset) *
scale), 0, canvasWidth); |
| 135 var end = Number.constrain(Math.ceil((event.endTime - timeOffset) * scal
e), 0, canvasWidth); | 135 var end = Number.constrain(Math.ceil((event.endTime - timeOffset) * scal
e), 0, canvasWidth); |
| 136 var width = Math.max(end - start, minWidth); | 136 var width = Math.max(end - start, minWidth); |
| 137 this._renderBar(start, start + width, 0, height, descriptor.color); | 137 this._renderBar(start, start + width, 0, height, descriptor.color); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * @unrestricted | 144 * @unrestricted |
| 145 */ | 145 */ |
| 146 WebInspector.TimelineEventOverviewNetwork = class extends WebInspector.TimelineE
ventOverview { | 146 Timeline.TimelineEventOverviewNetwork = class extends Timeline.TimelineEventOver
view { |
| 147 /** | 147 /** |
| 148 * @param {!WebInspector.TimelineModel} model | 148 * @param {!TimelineModel.TimelineModel} model |
| 149 */ | 149 */ |
| 150 constructor(model) { | 150 constructor(model) { |
| 151 super('network', WebInspector.UIString('NET'), model); | 151 super('network', Common.UIString('NET'), model); |
| 152 } | 152 } |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * @override | 155 * @override |
| 156 */ | 156 */ |
| 157 update() { | 157 update() { |
| 158 super.update(); | 158 super.update(); |
| 159 var height = this._canvas.height; | 159 var height = this._canvas.height; |
| 160 var numBands = categoryBand(WebInspector.TimelineUIUtils.NetworkCategory.Oth
er) + 1; | 160 var numBands = categoryBand(Timeline.TimelineUIUtils.NetworkCategory.Other)
+ 1; |
| 161 var bandHeight = Math.floor(height / numBands); | 161 var bandHeight = Math.floor(height / numBands); |
| 162 var devicePixelRatio = window.devicePixelRatio; | 162 var devicePixelRatio = window.devicePixelRatio; |
| 163 var timeOffset = this._model.minimumRecordTime(); | 163 var timeOffset = this._model.minimumRecordTime(); |
| 164 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 164 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 165 var canvasWidth = this._canvas.width; | 165 var canvasWidth = this._canvas.width; |
| 166 var scale = canvasWidth / timeSpan; | 166 var scale = canvasWidth / timeSpan; |
| 167 var ctx = this._context; | 167 var ctx = this._context; |
| 168 var requests = this._model.networkRequests(); | 168 var requests = this._model.networkRequests(); |
| 169 /** @type {!Map<string,!{waiting:!Path2D,transfer:!Path2D}>} */ | 169 /** @type {!Map<string,!{waiting:!Path2D,transfer:!Path2D}>} */ |
| 170 var paths = new Map(); | 170 var paths = new Map(); |
| 171 requests.forEach(drawRequest); | 171 requests.forEach(drawRequest); |
| 172 for (var path of paths) { | 172 for (var path of paths) { |
| 173 ctx.fillStyle = path[0]; | 173 ctx.fillStyle = path[0]; |
| 174 ctx.globalAlpha = 0.3; | 174 ctx.globalAlpha = 0.3; |
| 175 ctx.fill(path[1]['waiting']); | 175 ctx.fill(path[1]['waiting']); |
| 176 ctx.globalAlpha = 1; | 176 ctx.globalAlpha = 1; |
| 177 ctx.fill(path[1]['transfer']); | 177 ctx.fill(path[1]['transfer']); |
| 178 } | 178 } |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * @param {!WebInspector.TimelineUIUtils.NetworkCategory} category | 181 * @param {!Timeline.TimelineUIUtils.NetworkCategory} category |
| 182 * @return {number} | 182 * @return {number} |
| 183 */ | 183 */ |
| 184 function categoryBand(category) { | 184 function categoryBand(category) { |
| 185 var categories = WebInspector.TimelineUIUtils.NetworkCategory; | 185 var categories = Timeline.TimelineUIUtils.NetworkCategory; |
| 186 switch (category) { | 186 switch (category) { |
| 187 case categories.HTML: | 187 case categories.HTML: |
| 188 return 0; | 188 return 0; |
| 189 case categories.Script: | 189 case categories.Script: |
| 190 return 1; | 190 return 1; |
| 191 case categories.Style: | 191 case categories.Style: |
| 192 return 2; | 192 return 2; |
| 193 case categories.Media: | 193 case categories.Media: |
| 194 return 3; | 194 return 3; |
| 195 default: | 195 default: |
| 196 return 4; | 196 return 4; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 /** | 200 /** |
| 201 * @param {!WebInspector.TimelineModel.NetworkRequest} request | 201 * @param {!TimelineModel.TimelineModel.NetworkRequest} request |
| 202 */ | 202 */ |
| 203 function drawRequest(request) { | 203 function drawRequest(request) { |
| 204 var tickWidth = 2 * devicePixelRatio; | 204 var tickWidth = 2 * devicePixelRatio; |
| 205 var category = WebInspector.TimelineUIUtils.networkRequestCategory(request
); | 205 var category = Timeline.TimelineUIUtils.networkRequestCategory(request); |
| 206 var style = WebInspector.TimelineUIUtils.networkCategoryColor(category); | 206 var style = Timeline.TimelineUIUtils.networkCategoryColor(category); |
| 207 var band = categoryBand(category); | 207 var band = categoryBand(category); |
| 208 var y = band * bandHeight; | 208 var y = band * bandHeight; |
| 209 var path = paths.get(style); | 209 var path = paths.get(style); |
| 210 if (!path) { | 210 if (!path) { |
| 211 path = {waiting: new Path2D(), transfer: new Path2D()}; | 211 path = {waiting: new Path2D(), transfer: new Path2D()}; |
| 212 paths.set(style, path); | 212 paths.set(style, path); |
| 213 } | 213 } |
| 214 var s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0); | 214 var s = Math.max(Math.floor((request.startTime - timeOffset) * scale), 0); |
| 215 var e = Math.min(Math.ceil((request.endTime - timeOffset) * scale), canvas
Width); | 215 var e = Math.min(Math.ceil((request.endTime - timeOffset) * scale), canvas
Width); |
| 216 path['waiting'].rect(s, y, e - s, bandHeight - 1); | 216 path['waiting'].rect(s, y, e - s, bandHeight - 1); |
| 217 path['transfer'].rect(e - tickWidth / 2, y, tickWidth, bandHeight - 1); | 217 path['transfer'].rect(e - tickWidth / 2, y, tickWidth, bandHeight - 1); |
| 218 if (!request.responseTime) | 218 if (!request.responseTime) |
| 219 return; | 219 return; |
| 220 var r = Math.ceil((request.responseTime - timeOffset) * scale); | 220 var r = Math.ceil((request.responseTime - timeOffset) * scale); |
| 221 path['transfer'].rect(r - tickWidth / 2, y, tickWidth, bandHeight - 1); | 221 path['transfer'].rect(r - tickWidth / 2, y, tickWidth, bandHeight - 1); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 /** | 226 /** |
| 227 * @unrestricted | 227 * @unrestricted |
| 228 */ | 228 */ |
| 229 WebInspector.TimelineEventOverviewCPUActivity = class extends WebInspector.Timel
ineEventOverview { | 229 Timeline.TimelineEventOverviewCPUActivity = class extends Timeline.TimelineEvent
Overview { |
| 230 /** | 230 /** |
| 231 * @param {!WebInspector.TimelineModel} model | 231 * @param {!TimelineModel.TimelineModel} model |
| 232 */ | 232 */ |
| 233 constructor(model) { | 233 constructor(model) { |
| 234 super('cpu-activity', WebInspector.UIString('CPU'), model); | 234 super('cpu-activity', Common.UIString('CPU'), model); |
| 235 this._backgroundCanvas = this.element.createChild('canvas', 'fill background
'); | 235 this._backgroundCanvas = this.element.createChild('canvas', 'fill background
'); |
| 236 } | 236 } |
| 237 | 237 |
| 238 /** | 238 /** |
| 239 * @override | 239 * @override |
| 240 */ | 240 */ |
| 241 resetCanvas() { | 241 resetCanvas() { |
| 242 super.resetCanvas(); | 242 super.resetCanvas(); |
| 243 this._backgroundCanvas.width = this.element.clientWidth * window.devicePixel
Ratio; | 243 this._backgroundCanvas.width = this.element.clientWidth * window.devicePixel
Ratio; |
| 244 this._backgroundCanvas.height = this.element.clientHeight * window.devicePix
elRatio; | 244 this._backgroundCanvas.height = this.element.clientHeight * window.devicePix
elRatio; |
| 245 } | 245 } |
| 246 | 246 |
| 247 /** | 247 /** |
| 248 * @override | 248 * @override |
| 249 */ | 249 */ |
| 250 update() { | 250 update() { |
| 251 super.update(); | 251 super.update(); |
| 252 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; | 252 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; |
| 253 var width = this._canvas.width; | 253 var width = this._canvas.width; |
| 254 var height = this._canvas.height; | 254 var height = this._canvas.height; |
| 255 var baseLine = height; | 255 var baseLine = height; |
| 256 var timeOffset = this._model.minimumRecordTime(); | 256 var timeOffset = this._model.minimumRecordTime(); |
| 257 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 257 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 258 var scale = width / timeSpan; | 258 var scale = width / timeSpan; |
| 259 var quantTime = quantSizePx / scale; | 259 var quantTime = quantSizePx / scale; |
| 260 var categories = WebInspector.TimelineUIUtils.categories(); | 260 var categories = Timeline.TimelineUIUtils.categories(); |
| 261 var categoryOrder = ['idle', 'loading', 'painting', 'rendering', 'scripting'
, 'other']; | 261 var categoryOrder = ['idle', 'loading', 'painting', 'rendering', 'scripting'
, 'other']; |
| 262 var otherIndex = categoryOrder.indexOf('other'); | 262 var otherIndex = categoryOrder.indexOf('other'); |
| 263 var idleIndex = 0; | 263 var idleIndex = 0; |
| 264 console.assert(idleIndex === categoryOrder.indexOf('idle')); | 264 console.assert(idleIndex === categoryOrder.indexOf('idle')); |
| 265 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) | 265 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) |
| 266 categories[categoryOrder[i]]._overviewIndex = i; | 266 categories[categoryOrder[i]]._overviewIndex = i; |
| 267 | 267 |
| 268 var backgroundContext = this._backgroundCanvas.getContext('2d'); | 268 var backgroundContext = this._backgroundCanvas.getContext('2d'); |
| 269 for (var thread of this._model.virtualThreads()) | 269 for (var thread of this._model.virtualThreads()) |
| 270 drawThreadEvents(backgroundContext, thread.events); | 270 drawThreadEvents(backgroundContext, thread.events); |
| 271 applyPattern(backgroundContext); | 271 applyPattern(backgroundContext); |
| 272 drawThreadEvents(this._context, this._model.mainThreadEvents()); | 272 drawThreadEvents(this._context, this._model.mainThreadEvents()); |
| 273 | 273 |
| 274 /** | 274 /** |
| 275 * @param {!CanvasRenderingContext2D} ctx | 275 * @param {!CanvasRenderingContext2D} ctx |
| 276 * @param {!Array<!WebInspector.TracingModel.Event>} events | 276 * @param {!Array<!SDK.TracingModel.Event>} events |
| 277 */ | 277 */ |
| 278 function drawThreadEvents(ctx, events) { | 278 function drawThreadEvents(ctx, events) { |
| 279 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSamp
le); | 279 var quantizer = new Timeline.Quantizer(timeOffset, quantTime, drawSample); |
| 280 var x = 0; | 280 var x = 0; |
| 281 var categoryIndexStack = []; | 281 var categoryIndexStack = []; |
| 282 var paths = []; | 282 var paths = []; |
| 283 var lastY = []; | 283 var lastY = []; |
| 284 for (var i = 0; i < categoryOrder.length; ++i) { | 284 for (var i = 0; i < categoryOrder.length; ++i) { |
| 285 paths[i] = new Path2D(); | 285 paths[i] = new Path2D(); |
| 286 paths[i].moveTo(0, height); | 286 paths[i].moveTo(0, height); |
| 287 lastY[i] = height; | 287 lastY[i] = height; |
| 288 } | 288 } |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * @param {!Array<number>} counters | 291 * @param {!Array<number>} counters |
| 292 */ | 292 */ |
| 293 function drawSample(counters) { | 293 function drawSample(counters) { |
| 294 var y = baseLine; | 294 var y = baseLine; |
| 295 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) { | 295 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) { |
| 296 var h = (counters[i] || 0) / quantTime * height; | 296 var h = (counters[i] || 0) / quantTime * height; |
| 297 y -= h; | 297 y -= h; |
| 298 paths[i].bezierCurveTo(x, lastY[i], x, y, x + quantSizePx / 2, y); | 298 paths[i].bezierCurveTo(x, lastY[i], x, y, x + quantSizePx / 2, y); |
| 299 lastY[i] = y; | 299 lastY[i] = y; |
| 300 } | 300 } |
| 301 x += quantSizePx; | 301 x += quantSizePx; |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @param {!WebInspector.TracingModel.Event} e | 305 * @param {!SDK.TracingModel.Event} e |
| 306 */ | 306 */ |
| 307 function onEventStart(e) { | 307 function onEventStart(e) { |
| 308 var index = categoryIndexStack.length ? categoryIndexStack.peekLast() :
idleIndex; | 308 var index = categoryIndexStack.length ? categoryIndexStack.peekLast() :
idleIndex; |
| 309 quantizer.appendInterval(e.startTime, index); | 309 quantizer.appendInterval(e.startTime, index); |
| 310 categoryIndexStack.push(WebInspector.TimelineUIUtils.eventStyle(e).categ
ory._overviewIndex || otherIndex); | 310 categoryIndexStack.push(Timeline.TimelineUIUtils.eventStyle(e).category.
_overviewIndex || otherIndex); |
| 311 } | 311 } |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * @param {!WebInspector.TracingModel.Event} e | 314 * @param {!SDK.TracingModel.Event} e |
| 315 */ | 315 */ |
| 316 function onEventEnd(e) { | 316 function onEventEnd(e) { |
| 317 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); | 317 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); |
| 318 } | 318 } |
| 319 | 319 |
| 320 WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEventEnd); | 320 TimelineModel.TimelineModel.forEachEvent(events, onEventStart, onEventEnd)
; |
| 321 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleIndex); /
/ Kick drawing the last bucket. | 321 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleIndex); /
/ Kick drawing the last bucket. |
| 322 for (var i = categoryOrder.length - 1; i > 0; --i) { | 322 for (var i = categoryOrder.length - 1; i > 0; --i) { |
| 323 paths[i].lineTo(width, height); | 323 paths[i].lineTo(width, height); |
| 324 ctx.fillStyle = categories[categoryOrder[i]].color; | 324 ctx.fillStyle = categories[categoryOrder[i]].color; |
| 325 ctx.fill(paths[i]); | 325 ctx.fill(paths[i]); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 /** | 329 /** |
| 330 * @param {!CanvasRenderingContext2D} ctx | 330 * @param {!CanvasRenderingContext2D} ctx |
| 331 */ | 331 */ |
| 332 function applyPattern(ctx) { | 332 function applyPattern(ctx) { |
| 333 var step = 4 * window.devicePixelRatio; | 333 var step = 4 * window.devicePixelRatio; |
| 334 ctx.save(); | 334 ctx.save(); |
| 335 ctx.lineWidth = step / Math.sqrt(8); | 335 ctx.lineWidth = step / Math.sqrt(8); |
| 336 for (var x = 0.5; x < width + height; x += step) { | 336 for (var x = 0.5; x < width + height; x += step) { |
| 337 ctx.moveTo(x, 0); | 337 ctx.moveTo(x, 0); |
| 338 ctx.lineTo(x - height, height); | 338 ctx.lineTo(x - height, height); |
| 339 } | 339 } |
| 340 ctx.globalCompositeOperation = 'destination-out'; | 340 ctx.globalCompositeOperation = 'destination-out'; |
| 341 ctx.stroke(); | 341 ctx.stroke(); |
| 342 ctx.restore(); | 342 ctx.restore(); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 /** | 347 /** |
| 348 * @unrestricted | 348 * @unrestricted |
| 349 */ | 349 */ |
| 350 WebInspector.TimelineEventOverviewResponsiveness = class extends WebInspector.Ti
melineEventOverview { | 350 Timeline.TimelineEventOverviewResponsiveness = class extends Timeline.TimelineEv
entOverview { |
| 351 /** | 351 /** |
| 352 * @param {!WebInspector.TimelineModel} model | 352 * @param {!TimelineModel.TimelineModel} model |
| 353 * @param {!WebInspector.TimelineFrameModel} frameModel | 353 * @param {!TimelineModel.TimelineFrameModel} frameModel |
| 354 */ | 354 */ |
| 355 constructor(model, frameModel) { | 355 constructor(model, frameModel) { |
| 356 super('responsiveness', null, model); | 356 super('responsiveness', null, model); |
| 357 this._frameModel = frameModel; | 357 this._frameModel = frameModel; |
| 358 } | 358 } |
| 359 | 359 |
| 360 /** | 360 /** |
| 361 * @override | 361 * @override |
| 362 */ | 362 */ |
| 363 update() { | 363 update() { |
| 364 super.update(); | 364 super.update(); |
| 365 var height = this._canvas.height; | 365 var height = this._canvas.height; |
| 366 var timeOffset = this._model.minimumRecordTime(); | 366 var timeOffset = this._model.minimumRecordTime(); |
| 367 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 367 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
| 368 var scale = this._canvas.width / timeSpan; | 368 var scale = this._canvas.width / timeSpan; |
| 369 var frames = this._frameModel.frames(); | 369 var frames = this._frameModel.frames(); |
| 370 var ctx = this._context; | 370 var ctx = this._context; |
| 371 var fillPath = new Path2D(); | 371 var fillPath = new Path2D(); |
| 372 var markersPath = new Path2D(); | 372 var markersPath = new Path2D(); |
| 373 for (var i = 0; i < frames.length; ++i) { | 373 for (var i = 0; i < frames.length; ++i) { |
| 374 var frame = frames[i]; | 374 var frame = frames[i]; |
| 375 if (!frame.hasWarnings()) | 375 if (!frame.hasWarnings()) |
| 376 continue; | 376 continue; |
| 377 paintWarningDecoration(frame.startTime, frame.duration); | 377 paintWarningDecoration(frame.startTime, frame.duration); |
| 378 } | 378 } |
| 379 | 379 |
| 380 var events = this._model.mainThreadEvents(); | 380 var events = this._model.mainThreadEvents(); |
| 381 for (var i = 0; i < events.length; ++i) { | 381 for (var i = 0; i < events.length; ++i) { |
| 382 if (!WebInspector.TimelineData.forEvent(events[i]).warning) | 382 if (!TimelineModel.TimelineData.forEvent(events[i]).warning) |
| 383 continue; | 383 continue; |
| 384 paintWarningDecoration(events[i].startTime, events[i].duration); | 384 paintWarningDecoration(events[i].startTime, events[i].duration); |
| 385 } | 385 } |
| 386 | 386 |
| 387 ctx.fillStyle = 'hsl(0, 80%, 90%)'; | 387 ctx.fillStyle = 'hsl(0, 80%, 90%)'; |
| 388 ctx.strokeStyle = 'red'; | 388 ctx.strokeStyle = 'red'; |
| 389 ctx.lineWidth = 2 * window.devicePixelRatio; | 389 ctx.lineWidth = 2 * window.devicePixelRatio; |
| 390 ctx.fill(fillPath); | 390 ctx.fill(fillPath); |
| 391 ctx.stroke(markersPath); | 391 ctx.stroke(markersPath); |
| 392 | 392 |
| 393 /** | 393 /** |
| 394 * @param {number} time | 394 * @param {number} time |
| 395 * @param {number} duration | 395 * @param {number} duration |
| 396 */ | 396 */ |
| 397 function paintWarningDecoration(time, duration) { | 397 function paintWarningDecoration(time, duration) { |
| 398 var x = Math.round(scale * (time - timeOffset)); | 398 var x = Math.round(scale * (time - timeOffset)); |
| 399 var w = Math.round(scale * duration); | 399 var w = Math.round(scale * duration); |
| 400 fillPath.rect(x, 0, w, height); | 400 fillPath.rect(x, 0, w, height); |
| 401 markersPath.moveTo(x + w, 0); | 401 markersPath.moveTo(x + w, 0); |
| 402 markersPath.lineTo(x + w, height); | 402 markersPath.lineTo(x + w, height); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 }; | 405 }; |
| 406 | 406 |
| 407 /** | 407 /** |
| 408 * @unrestricted | 408 * @unrestricted |
| 409 */ | 409 */ |
| 410 WebInspector.TimelineFilmStripOverview = class extends WebInspector.TimelineEven
tOverview { | 410 Timeline.TimelineFilmStripOverview = class extends Timeline.TimelineEventOvervie
w { |
| 411 /** | 411 /** |
| 412 * @param {!WebInspector.TimelineModel} model | 412 * @param {!TimelineModel.TimelineModel} model |
| 413 * @param {!WebInspector.FilmStripModel} filmStripModel | 413 * @param {!Components.FilmStripModel} filmStripModel |
| 414 */ | 414 */ |
| 415 constructor(model, filmStripModel) { | 415 constructor(model, filmStripModel) { |
| 416 super('filmstrip', null, model); | 416 super('filmstrip', null, model); |
| 417 this._filmStripModel = filmStripModel; | 417 this._filmStripModel = filmStripModel; |
| 418 this.reset(); | 418 this.reset(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 /** | 421 /** |
| 422 * @override | 422 * @override |
| 423 */ | 423 */ |
| 424 update() { | 424 update() { |
| 425 super.update(); | 425 super.update(); |
| 426 var frames = this._filmStripModel.frames(); | 426 var frames = this._filmStripModel.frames(); |
| 427 if (!frames.length) | 427 if (!frames.length) |
| 428 return; | 428 return; |
| 429 | 429 |
| 430 var drawGeneration = Symbol('drawGeneration'); | 430 var drawGeneration = Symbol('drawGeneration'); |
| 431 this._drawGeneration = drawGeneration; | 431 this._drawGeneration = drawGeneration; |
| 432 this._imageByFrame(frames[0]).then(image => { | 432 this._imageByFrame(frames[0]).then(image => { |
| 433 if (this._drawGeneration !== drawGeneration) | 433 if (this._drawGeneration !== drawGeneration) |
| 434 return; | 434 return; |
| 435 if (!image.naturalWidth || !image.naturalHeight) | 435 if (!image.naturalWidth || !image.naturalHeight) |
| 436 return; | 436 return; |
| 437 var imageHeight = this._canvas.height - 2 * WebInspector.TimelineFilmStrip
Overview.Padding; | 437 var imageHeight = this._canvas.height - 2 * Timeline.TimelineFilmStripOver
view.Padding; |
| 438 var imageWidth = Math.ceil(imageHeight * image.naturalWidth / image.natura
lHeight); | 438 var imageWidth = Math.ceil(imageHeight * image.naturalWidth / image.natura
lHeight); |
| 439 var popoverScale = Math.min(200 / image.naturalWidth, 1); | 439 var popoverScale = Math.min(200 / image.naturalWidth, 1); |
| 440 this._emptyImage = new Image(image.naturalWidth * popoverScale, image.natu
ralHeight * popoverScale); | 440 this._emptyImage = new Image(image.naturalWidth * popoverScale, image.natu
ralHeight * popoverScale); |
| 441 this._drawFrames(imageWidth, imageHeight); | 441 this._drawFrames(imageWidth, imageHeight); |
| 442 }); | 442 }); |
| 443 } | 443 } |
| 444 | 444 |
| 445 /** | 445 /** |
| 446 * @param {!WebInspector.FilmStripModel.Frame} frame | 446 * @param {!Components.FilmStripModel.Frame} frame |
| 447 * @return {!Promise<!HTMLImageElement>} | 447 * @return {!Promise<!HTMLImageElement>} |
| 448 */ | 448 */ |
| 449 _imageByFrame(frame) { | 449 _imageByFrame(frame) { |
| 450 var imagePromise = this._frameToImagePromise.get(frame); | 450 var imagePromise = this._frameToImagePromise.get(frame); |
| 451 if (!imagePromise) { | 451 if (!imagePromise) { |
| 452 imagePromise = frame.imageDataPromise().then(createImage); | 452 imagePromise = frame.imageDataPromise().then(createImage); |
| 453 this._frameToImagePromise.set(frame, imagePromise); | 453 this._frameToImagePromise.set(frame, imagePromise); |
| 454 } | 454 } |
| 455 return imagePromise; | 455 return imagePromise; |
| 456 | 456 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 477 | 477 |
| 478 /** | 478 /** |
| 479 * @param {number} imageWidth | 479 * @param {number} imageWidth |
| 480 * @param {number} imageHeight | 480 * @param {number} imageHeight |
| 481 */ | 481 */ |
| 482 _drawFrames(imageWidth, imageHeight) { | 482 _drawFrames(imageWidth, imageHeight) { |
| 483 if (!imageWidth) | 483 if (!imageWidth) |
| 484 return; | 484 return; |
| 485 if (!this._filmStripModel.frames().length) | 485 if (!this._filmStripModel.frames().length) |
| 486 return; | 486 return; |
| 487 var padding = WebInspector.TimelineFilmStripOverview.Padding; | 487 var padding = Timeline.TimelineFilmStripOverview.Padding; |
| 488 var width = this._canvas.width; | 488 var width = this._canvas.width; |
| 489 var zeroTime = this._filmStripModel.zeroTime(); | 489 var zeroTime = this._filmStripModel.zeroTime(); |
| 490 var spanTime = this._filmStripModel.spanTime(); | 490 var spanTime = this._filmStripModel.spanTime(); |
| 491 var scale = spanTime / width; | 491 var scale = spanTime / width; |
| 492 var context = this._canvas.getContext('2d'); | 492 var context = this._canvas.getContext('2d'); |
| 493 var drawGeneration = this._drawGeneration; | 493 var drawGeneration = this._drawGeneration; |
| 494 | 494 |
| 495 context.beginPath(); | 495 context.beginPath(); |
| 496 for (var x = padding; x < width; x += imageWidth + 2 * padding) { | 496 for (var x = padding; x < width; x += imageWidth + 2 * padding) { |
| 497 var time = zeroTime + (x + imageWidth / 2) * scale; | 497 var time = zeroTime + (x + imageWidth / 2) * scale; |
| 498 var frame = this._filmStripModel.frameByTimestamp(time); | 498 var frame = this._filmStripModel.frameByTimestamp(time); |
| 499 if (!frame) | 499 if (!frame) |
| 500 continue; | 500 continue; |
| 501 context.rect(x - 0.5, 0.5, imageWidth + 1, imageHeight + 1); | 501 context.rect(x - 0.5, 0.5, imageWidth + 1, imageHeight + 1); |
| 502 this._imageByFrame(frame).then(drawFrameImage.bind(this, x)); | 502 this._imageByFrame(frame).then(drawFrameImage.bind(this, x)); |
| 503 } | 503 } |
| 504 context.strokeStyle = '#ddd'; | 504 context.strokeStyle = '#ddd'; |
| 505 context.stroke(); | 505 context.stroke(); |
| 506 | 506 |
| 507 /** | 507 /** |
| 508 * @param {number} x | 508 * @param {number} x |
| 509 * @param {!HTMLImageElement} image | 509 * @param {!HTMLImageElement} image |
| 510 * @this {WebInspector.TimelineFilmStripOverview} | 510 * @this {Timeline.TimelineFilmStripOverview} |
| 511 */ | 511 */ |
| 512 function drawFrameImage(x, image) { | 512 function drawFrameImage(x, image) { |
| 513 // Ignore draws deferred from a previous update call. | 513 // Ignore draws deferred from a previous update call. |
| 514 if (this._drawGeneration !== drawGeneration) | 514 if (this._drawGeneration !== drawGeneration) |
| 515 return; | 515 return; |
| 516 context.drawImage(image, x, 1, imageWidth, imageHeight); | 516 context.drawImage(image, x, 1, imageWidth, imageHeight); |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 /** | 520 /** |
| 521 * @override | 521 * @override |
| 522 * @param {number} x | 522 * @param {number} x |
| 523 * @return {!Promise<?Element>} | 523 * @return {!Promise<?Element>} |
| 524 */ | 524 */ |
| 525 popoverElementPromise(x) { | 525 popoverElementPromise(x) { |
| 526 if (!this._filmStripModel.frames().length) | 526 if (!this._filmStripModel.frames().length) |
| 527 return Promise.resolve(/** @type {?Element} */ (null)); | 527 return Promise.resolve(/** @type {?Element} */ (null)); |
| 528 | 528 |
| 529 var time = this._calculator.positionToTime(x); | 529 var time = this._calculator.positionToTime(x); |
| 530 var frame = this._filmStripModel.frameByTimestamp(time); | 530 var frame = this._filmStripModel.frameByTimestamp(time); |
| 531 if (frame === this._lastFrame) | 531 if (frame === this._lastFrame) |
| 532 return Promise.resolve(this._lastElement); | 532 return Promise.resolve(this._lastElement); |
| 533 var imagePromise = frame ? this._imageByFrame(frame) : Promise.resolve(this.
_emptyImage); | 533 var imagePromise = frame ? this._imageByFrame(frame) : Promise.resolve(this.
_emptyImage); |
| 534 return imagePromise.then(createFrameElement.bind(this)); | 534 return imagePromise.then(createFrameElement.bind(this)); |
| 535 | 535 |
| 536 /** | 536 /** |
| 537 * @this {WebInspector.TimelineFilmStripOverview} | 537 * @this {Timeline.TimelineFilmStripOverview} |
| 538 * @param {!HTMLImageElement} image | 538 * @param {!HTMLImageElement} image |
| 539 * @return {?Element} | 539 * @return {?Element} |
| 540 */ | 540 */ |
| 541 function createFrameElement(image) { | 541 function createFrameElement(image) { |
| 542 var element = createElementWithClass('div', 'frame'); | 542 var element = createElementWithClass('div', 'frame'); |
| 543 element.createChild('div', 'thumbnail').appendChild(image); | 543 element.createChild('div', 'thumbnail').appendChild(image); |
| 544 WebInspector.appendStyle(element, 'timeline/timelinePanel.css'); | 544 UI.appendStyle(element, 'timeline/timelinePanel.css'); |
| 545 this._lastFrame = frame; | 545 this._lastFrame = frame; |
| 546 this._lastElement = element; | 546 this._lastElement = element; |
| 547 return element; | 547 return element; |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 | 550 |
| 551 /** | 551 /** |
| 552 * @override | 552 * @override |
| 553 */ | 553 */ |
| 554 reset() { | 554 reset() { |
| 555 this._lastFrame = undefined; | 555 this._lastFrame = undefined; |
| 556 this._lastElement = null; | 556 this._lastElement = null; |
| 557 /** @type {!Map<!WebInspector.FilmStripModel.Frame,!Promise<!HTMLImageElemen
t>>} */ | 557 /** @type {!Map<!Components.FilmStripModel.Frame,!Promise<!HTMLImageElement>
>} */ |
| 558 this._frameToImagePromise = new Map(); | 558 this._frameToImagePromise = new Map(); |
| 559 this._imageWidth = 0; | 559 this._imageWidth = 0; |
| 560 } | 560 } |
| 561 }; | 561 }; |
| 562 | 562 |
| 563 WebInspector.TimelineFilmStripOverview.Padding = 2; | 563 Timeline.TimelineFilmStripOverview.Padding = 2; |
| 564 | 564 |
| 565 /** | 565 /** |
| 566 * @unrestricted | 566 * @unrestricted |
| 567 */ | 567 */ |
| 568 WebInspector.TimelineEventOverviewFrames = class extends WebInspector.TimelineEv
entOverview { | 568 Timeline.TimelineEventOverviewFrames = class extends Timeline.TimelineEventOverv
iew { |
| 569 /** | 569 /** |
| 570 * @param {!WebInspector.TimelineModel} model | 570 * @param {!TimelineModel.TimelineModel} model |
| 571 * @param {!WebInspector.TimelineFrameModel} frameModel | 571 * @param {!TimelineModel.TimelineFrameModel} frameModel |
| 572 */ | 572 */ |
| 573 constructor(model, frameModel) { | 573 constructor(model, frameModel) { |
| 574 super('framerate', WebInspector.UIString('FPS'), model); | 574 super('framerate', Common.UIString('FPS'), model); |
| 575 this._frameModel = frameModel; | 575 this._frameModel = frameModel; |
| 576 } | 576 } |
| 577 | 577 |
| 578 /** | 578 /** |
| 579 * @override | 579 * @override |
| 580 */ | 580 */ |
| 581 update() { | 581 update() { |
| 582 super.update(); | 582 super.update(); |
| 583 var height = this._canvas.height; | 583 var height = this._canvas.height; |
| 584 var /** @const */ padding = 1 * window.devicePixelRatio; | 584 var /** @const */ padding = 1 * window.devicePixelRatio; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 ctx.strokeStyle = 'hsl(110, 50%, 60%)'; | 620 ctx.strokeStyle = 'hsl(110, 50%, 60%)'; |
| 621 ctx.lineWidth = lineWidth; | 621 ctx.lineWidth = lineWidth; |
| 622 ctx.fill(); | 622 ctx.fill(); |
| 623 ctx.stroke(); | 623 ctx.stroke(); |
| 624 } | 624 } |
| 625 }; | 625 }; |
| 626 | 626 |
| 627 /** | 627 /** |
| 628 * @unrestricted | 628 * @unrestricted |
| 629 */ | 629 */ |
| 630 WebInspector.TimelineEventOverviewMemory = class extends WebInspector.TimelineEv
entOverview { | 630 Timeline.TimelineEventOverviewMemory = class extends Timeline.TimelineEventOverv
iew { |
| 631 /** | 631 /** |
| 632 * @param {!WebInspector.TimelineModel} model | 632 * @param {!TimelineModel.TimelineModel} model |
| 633 */ | 633 */ |
| 634 constructor(model) { | 634 constructor(model) { |
| 635 super('memory', WebInspector.UIString('HEAP'), model); | 635 super('memory', Common.UIString('HEAP'), model); |
| 636 this._heapSizeLabel = this.element.createChild('div', 'memory-graph-label'); | 636 this._heapSizeLabel = this.element.createChild('div', 'memory-graph-label'); |
| 637 } | 637 } |
| 638 | 638 |
| 639 resetHeapSizeLabels() { | 639 resetHeapSizeLabels() { |
| 640 this._heapSizeLabel.textContent = ''; | 640 this._heapSizeLabel.textContent = ''; |
| 641 } | 641 } |
| 642 | 642 |
| 643 /** | 643 /** |
| 644 * @override | 644 * @override |
| 645 */ | 645 */ |
| 646 update() { | 646 update() { |
| 647 super.update(); | 647 super.update(); |
| 648 var ratio = window.devicePixelRatio; | 648 var ratio = window.devicePixelRatio; |
| 649 | 649 |
| 650 var events = this._model.mainThreadEvents(); | 650 var events = this._model.mainThreadEvents(); |
| 651 if (!events.length) { | 651 if (!events.length) { |
| 652 this.resetHeapSizeLabels(); | 652 this.resetHeapSizeLabels(); |
| 653 return; | 653 return; |
| 654 } | 654 } |
| 655 | 655 |
| 656 var lowerOffset = 3 * ratio; | 656 var lowerOffset = 3 * ratio; |
| 657 var maxUsedHeapSize = 0; | 657 var maxUsedHeapSize = 0; |
| 658 var minUsedHeapSize = 100000000000; | 658 var minUsedHeapSize = 100000000000; |
| 659 var minTime = this._model.minimumRecordTime(); | 659 var minTime = this._model.minimumRecordTime(); |
| 660 var maxTime = this._model.maximumRecordTime(); | 660 var maxTime = this._model.maximumRecordTime(); |
| 661 /** | 661 /** |
| 662 * @param {!WebInspector.TracingModel.Event} event | 662 * @param {!SDK.TracingModel.Event} event |
| 663 * @return {boolean} | 663 * @return {boolean} |
| 664 */ | 664 */ |
| 665 function isUpdateCountersEvent(event) { | 665 function isUpdateCountersEvent(event) { |
| 666 return event.name === WebInspector.TimelineModel.RecordType.UpdateCounters
; | 666 return event.name === TimelineModel.TimelineModel.RecordType.UpdateCounter
s; |
| 667 } | 667 } |
| 668 events = events.filter(isUpdateCountersEvent); | 668 events = events.filter(isUpdateCountersEvent); |
| 669 /** | 669 /** |
| 670 * @param {!WebInspector.TracingModel.Event} event | 670 * @param {!SDK.TracingModel.Event} event |
| 671 */ | 671 */ |
| 672 function calculateMinMaxSizes(event) { | 672 function calculateMinMaxSizes(event) { |
| 673 var counters = event.args.data; | 673 var counters = event.args.data; |
| 674 if (!counters || !counters.jsHeapSizeUsed) | 674 if (!counters || !counters.jsHeapSizeUsed) |
| 675 return; | 675 return; |
| 676 maxUsedHeapSize = Math.max(maxUsedHeapSize, counters.jsHeapSizeUsed); | 676 maxUsedHeapSize = Math.max(maxUsedHeapSize, counters.jsHeapSizeUsed); |
| 677 minUsedHeapSize = Math.min(minUsedHeapSize, counters.jsHeapSizeUsed); | 677 minUsedHeapSize = Math.min(minUsedHeapSize, counters.jsHeapSizeUsed); |
| 678 } | 678 } |
| 679 events.forEach(calculateMinMaxSizes); | 679 events.forEach(calculateMinMaxSizes); |
| 680 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize); | 680 minUsedHeapSize = Math.min(minUsedHeapSize, maxUsedHeapSize); |
| 681 | 681 |
| 682 var lineWidth = 1; | 682 var lineWidth = 1; |
| 683 var width = this._canvas.width; | 683 var width = this._canvas.width; |
| 684 var height = this._canvas.height - lowerOffset; | 684 var height = this._canvas.height - lowerOffset; |
| 685 var xFactor = width / (maxTime - minTime); | 685 var xFactor = width / (maxTime - minTime); |
| 686 var yFactor = (height - lineWidth) / Math.max(maxUsedHeapSize - minUsedHeapS
ize, 1); | 686 var yFactor = (height - lineWidth) / Math.max(maxUsedHeapSize - minUsedHeapS
ize, 1); |
| 687 | 687 |
| 688 var histogram = new Array(width); | 688 var histogram = new Array(width); |
| 689 | 689 |
| 690 /** | 690 /** |
| 691 * @param {!WebInspector.TracingModel.Event} event | 691 * @param {!SDK.TracingModel.Event} event |
| 692 */ | 692 */ |
| 693 function buildHistogram(event) { | 693 function buildHistogram(event) { |
| 694 var counters = event.args.data; | 694 var counters = event.args.data; |
| 695 if (!counters || !counters.jsHeapSizeUsed) | 695 if (!counters || !counters.jsHeapSizeUsed) |
| 696 return; | 696 return; |
| 697 var x = Math.round((event.startTime - minTime) * xFactor); | 697 var x = Math.round((event.startTime - minTime) * xFactor); |
| 698 var y = Math.round((counters.jsHeapSizeUsed - minUsedHeapSize) * yFactor); | 698 var y = Math.round((counters.jsHeapSizeUsed - minUsedHeapSize) * yFactor); |
| 699 histogram[x] = Math.max(histogram[x] || 0, y); | 699 histogram[x] = Math.max(histogram[x] || 0, y); |
| 700 } | 700 } |
| 701 events.forEach(buildHistogram); | 701 events.forEach(buildHistogram); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 727 ctx.lineTo(width + lineWidth, height - y); | 727 ctx.lineTo(width + lineWidth, height - y); |
| 728 ctx.lineTo(width + lineWidth, heightBeyondView); | 728 ctx.lineTo(width + lineWidth, heightBeyondView); |
| 729 ctx.closePath(); | 729 ctx.closePath(); |
| 730 | 730 |
| 731 ctx.fillStyle = 'hsla(220, 90%, 70%, 0.2)'; | 731 ctx.fillStyle = 'hsla(220, 90%, 70%, 0.2)'; |
| 732 ctx.fill(); | 732 ctx.fill(); |
| 733 ctx.lineWidth = lineWidth; | 733 ctx.lineWidth = lineWidth; |
| 734 ctx.strokeStyle = 'hsl(220, 90%, 70%)'; | 734 ctx.strokeStyle = 'hsl(220, 90%, 70%)'; |
| 735 ctx.stroke(); | 735 ctx.stroke(); |
| 736 | 736 |
| 737 this._heapSizeLabel.textContent = WebInspector.UIString( | 737 this._heapSizeLabel.textContent = Common.UIString( |
| 738 '%s \u2013 %s', Number.bytesToString(minUsedHeapSize), Number.bytesToStr
ing(maxUsedHeapSize)); | 738 '%s \u2013 %s', Number.bytesToString(minUsedHeapSize), Number.bytesToStr
ing(maxUsedHeapSize)); |
| 739 } | 739 } |
| 740 }; | 740 }; |
| 741 | 741 |
| 742 /** | 742 /** |
| 743 * @unrestricted | 743 * @unrestricted |
| 744 */ | 744 */ |
| 745 WebInspector.Quantizer = class { | 745 Timeline.Quantizer = class { |
| 746 /** | 746 /** |
| 747 * @param {number} startTime | 747 * @param {number} startTime |
| 748 * @param {number} quantDuration | 748 * @param {number} quantDuration |
| 749 * @param {function(!Array<number>)} callback | 749 * @param {function(!Array<number>)} callback |
| 750 */ | 750 */ |
| 751 constructor(startTime, quantDuration, callback) { | 751 constructor(startTime, quantDuration, callback) { |
| 752 this._lastTime = startTime; | 752 this._lastTime = startTime; |
| 753 this._quantDuration = quantDuration; | 753 this._quantDuration = quantDuration; |
| 754 this._callback = callback; | 754 this._callback = callback; |
| 755 this._counters = []; | 755 this._counters = []; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 776 counters[group] = this._quantDuration; | 776 counters[group] = this._quantDuration; |
| 777 this._callback(counters); | 777 this._callback(counters); |
| 778 interval -= this._quantDuration; | 778 interval -= this._quantDuration; |
| 779 } | 779 } |
| 780 this._counters = []; | 780 this._counters = []; |
| 781 this._counters[group] = interval; | 781 this._counters[group] = interval; |
| 782 this._lastTime = time; | 782 this._lastTime = time; |
| 783 this._remainder = this._quantDuration - interval; | 783 this._remainder = this._quantDuration - interval; |
| 784 } | 784 } |
| 785 }; | 785 }; |
| OLD | NEW |