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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 path["transfer"].rect(r - tickWidth / 2, y, tickWidth, bandHeight - 1); | 247 path["transfer"].rect(r - tickWidth / 2, y, tickWidth, bandHeight - 1); |
248 } | 248 } |
249 }, | 249 }, |
250 | 250 |
251 __proto__: WebInspector.TimelineEventOverview.prototype | 251 __proto__: WebInspector.TimelineEventOverview.prototype |
252 } | 252 } |
253 | 253 |
254 /** | 254 /** |
255 * @constructor | 255 * @constructor |
256 * @extends {WebInspector.TimelineEventOverview} | 256 * @extends {WebInspector.TimelineEventOverview} |
257 * @param {string} id | |
258 * @param {string} title | |
259 * @param {!WebInspector.TimelineModel} model | 257 * @param {!WebInspector.TimelineModel} model |
260 */ | 258 */ |
261 WebInspector.TimelineEventOverview.Thread = function(id, title, model) | 259 WebInspector.TimelineEventOverview.CPUActivity = function(model) |
262 { | 260 { |
263 WebInspector.TimelineEventOverview.call(this, id, title, model) | 261 WebInspector.TimelineEventOverview.call(this, "cpu-activity", WebInspector.U IString("CPU"), model); |
264 this._fillStyles = {}; | 262 this._fillStyles = {}; |
265 var categories = WebInspector.TimelineUIUtils.categories(); | 263 var categories = WebInspector.TimelineUIUtils.categories(); |
266 for (var category in categories) { | 264 for (var category in categories) { |
267 this._fillStyles[category] = categories[category].fillColorStop1; | 265 this._fillStyles[category] = categories[category].fillColorStop1; |
268 categories[category].addEventListener(WebInspector.TimelineCategory.Even ts.VisibilityChanged, this._onCategoryVisibilityChanged, this); | 266 categories[category].addEventListener(WebInspector.TimelineCategory.Even ts.VisibilityChanged, this._onCategoryVisibilityChanged, this); |
269 } | 267 } |
270 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; | 268 this._disabledCategoryFillStyle = "hsl(0, 0%, 67%)"; |
269 this._backgroundCanvas = this.element.createChild("canvas", "fill background "); | |
271 } | 270 } |
272 | 271 |
273 WebInspector.TimelineEventOverview.Thread.prototype = { | 272 WebInspector.TimelineEventOverview.CPUActivity.prototype = { |
274 /** | 273 /** |
275 * @override | 274 * @override |
276 */ | 275 */ |
277 dispose: function() | 276 dispose: function() |
278 { | 277 { |
279 WebInspector.TimelineOverviewBase.prototype.dispose.call(this); | 278 WebInspector.TimelineOverviewBase.prototype.dispose.call(this); |
280 var categories = WebInspector.TimelineUIUtils.categories(); | 279 var categories = WebInspector.TimelineUIUtils.categories(); |
281 for (var category in categories) | 280 for (var category in categories) |
282 categories[category].removeEventListener(WebInspector.TimelineCatego ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); | 281 categories[category].removeEventListener(WebInspector.TimelineCatego ry.Events.VisibilityChanged, this._onCategoryVisibilityChanged, this); |
283 }, | 282 }, |
284 | 283 |
285 _onCategoryVisibilityChanged: function() | 284 _onCategoryVisibilityChanged: function() |
286 { | 285 { |
287 this.update(); | 286 this.update(); |
288 }, | 287 }, |
289 | 288 |
290 /** | 289 /** |
291 * @param {!WebInspector.TimelineCategory} category | 290 * @param {!WebInspector.TimelineCategory} category |
292 * @return {string} | 291 * @return {string} |
293 */ | 292 */ |
294 _categoryColor: function(category) | 293 _categoryColor: function(category) |
295 { | 294 { |
296 return category.hidden ? this._disabledCategoryFillStyle : this._fillSty les[category.name]; | 295 return category.hidden ? this._disabledCategoryFillStyle : this._fillSty les[category.name]; |
297 }, | 296 }, |
298 | 297 |
299 __proto__: WebInspector.TimelineEventOverview.prototype | 298 /** |
300 } | 299 * @override |
300 */ | |
301 resetCanvas: function() | |
302 { | |
303 WebInspector.TimelineEventOverview.prototype.resetCanvas.call(this); | |
304 this._backgroundCanvas.width = this.element.clientWidth * window.deviceP ixelRatio; | |
305 this._backgroundCanvas.height = this.element.clientHeight * window.devic ePixelRatio; | |
306 }, | |
301 | 307 |
302 /** | |
303 * @constructor | |
304 * @extends {WebInspector.TimelineEventOverview.Thread} | |
305 * @param {!WebInspector.TimelineModel} model | |
306 */ | |
307 WebInspector.TimelineEventOverview.MainThread = function(model) | |
308 { | |
309 WebInspector.TimelineEventOverview.Thread.call(this, "main-thread", WebInspe ctor.UIString("CPU"), model) | |
310 } | |
311 | |
312 WebInspector.TimelineEventOverview.MainThread.prototype = { | |
313 /** | 308 /** |
314 * @override | 309 * @override |
315 */ | 310 */ |
316 update: function() | 311 update: function() |
317 { | 312 { |
318 WebInspector.TimelineEventOverview.prototype.update.call(this); | 313 WebInspector.TimelineEventOverview.prototype.update.call(this); |
319 var events = this._model.mainThreadEvents(); | |
320 if (!events.length) | |
321 return; | |
322 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; | 314 var /** @const */ quantSizePx = 4 * window.devicePixelRatio; |
323 var height = this._canvas.height; | 315 var height = this._canvas.height; |
324 var baseLine = height; | 316 var baseLine = height; |
325 var timeOffset = this._model.minimumRecordTime(); | 317 var timeOffset = this._model.minimumRecordTime(); |
326 var timeSpan = this._model.maximumRecordTime() - timeOffset; | 318 var timeSpan = this._model.maximumRecordTime() - timeOffset; |
327 var scale = this._canvas.width / timeSpan; | 319 var scale = this._canvas.width / timeSpan; |
328 var quantTime = quantSizePx / scale; | 320 var quantTime = quantSizePx / scale; |
329 var quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSa mple.bind(this)); | 321 var quantizer; |
330 var ctx = this._context; | |
331 var x = 0; | 322 var x = 0; |
332 var categories = WebInspector.TimelineUIUtils.categories(); | 323 var categories = WebInspector.TimelineUIUtils.categories(); |
333 var categoryOrder = ["idle", "loading", "painting", "rendering", "script ing", "other"]; | 324 var categoryOrder = ["idle", "loading", "painting", "rendering", "script ing", "other"]; |
334 var otherIndex = categoryOrder.indexOf("other"); | 325 var otherIndex = categoryOrder.indexOf("other"); |
335 var idleIndex = 0; | 326 var idleIndex = 0; |
336 console.assert(idleIndex === categoryOrder.indexOf("idle")); | 327 console.assert(idleIndex === categoryOrder.indexOf("idle")); |
337 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) | 328 for (var i = idleIndex + 1; i < categoryOrder.length; ++i) |
338 categories[categoryOrder[i]]._overviewIndex = i; | 329 categories[categoryOrder[i]]._overviewIndex = i; |
339 var categoryIndexStack = []; | 330 var categoryIndexStack = []; |
340 | 331 |
332 var ctx = this._backgroundCanvas.getContext("2d"); | |
333 this._model.virtualThreads().forEach(function (thread) { drawThreadEvent s.call(this, thread.events); }, this); | |
caseq
2015/08/25 01:37:56
extract a named function?
alph
2015/08/25 17:29:26
Done.
| |
334 ctx = this._context; | |
caseq
2015/08/25 01:37:56
can we pass this explicitly rather than swap the c
alph
2015/08/25 17:29:26
Done.
| |
335 drawThreadEvents.call(this, this._model.mainThreadEvents()); | |
336 | |
341 /** | 337 /** |
342 * @param {!Array<number>} counters | 338 * @param {!Array<number>} counters |
343 * @this {WebInspector.TimelineEventOverview} | 339 * @this {WebInspector.TimelineEventOverview} |
344 */ | 340 */ |
345 function drawSample(counters) | 341 function drawSample(counters) |
346 { | 342 { |
347 var y = baseLine; | 343 var y = baseLine; |
348 for (var i = idleIndex + 1; i < counters.length; ++i) { | 344 for (var i = idleIndex + 1; i < counters.length; ++i) { |
349 if (!counters[i]) | 345 if (!counters[i]) |
350 continue; | 346 continue; |
(...skipping 16 matching lines...) Expand all Loading... | |
367 } | 363 } |
368 | 364 |
369 /** | 365 /** |
370 * @param {!WebInspector.TracingModel.Event} e | 366 * @param {!WebInspector.TracingModel.Event} e |
371 */ | 367 */ |
372 function onEventEnd(e) | 368 function onEventEnd(e) |
373 { | 369 { |
374 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); | 370 quantizer.appendInterval(e.endTime, categoryIndexStack.pop()); |
375 } | 371 } |
376 | 372 |
377 WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEventEnd ); | 373 /** |
378 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleIndex); // Kick drawing the last bucket. | 374 * @param {!Array<!WebInspector.TracingModel.Event>} events |
375 * @this {WebInspector.TimelineEventOverview} | |
376 */ | |
377 function drawThreadEvents(events) | |
378 { | |
379 quantizer = new WebInspector.Quantizer(timeOffset, quantTime, drawSa mple.bind(this)); | |
380 x = 0; | |
381 categoryIndexStack = []; | |
caseq
2015/08/25 01:37:56
The above three look scary and puzzling, too!
alph
2015/08/25 17:29:26
Done.
| |
382 WebInspector.TimelineModel.forEachEvent(events, onEventStart, onEven tEnd); | |
383 quantizer.appendInterval(timeOffset + timeSpan + quantTime, idleInde x); // Kick drawing the last bucket. | |
384 } | |
379 }, | 385 }, |
380 | 386 |
381 __proto__: WebInspector.TimelineEventOverview.Thread.prototype | 387 __proto__: WebInspector.TimelineEventOverview.prototype |
382 } | 388 } |
383 | 389 |
384 /** | 390 /** |
385 * @constructor | 391 * @constructor |
386 * @extends {WebInspector.TimelineEventOverview} | 392 * @extends {WebInspector.TimelineEventOverview} |
387 * @param {!WebInspector.TimelineModel} model | 393 * @param {!WebInspector.TimelineModel} model |
388 * @param {!WebInspector.TimelineFrameModelBase} frameModel | 394 * @param {!WebInspector.TimelineFrameModelBase} frameModel |
389 */ | 395 */ |
390 WebInspector.TimelineEventOverview.Responsiveness = function(model, frameModel) | 396 WebInspector.TimelineEventOverview.Responsiveness = function(model, frameModel) |
391 { | 397 { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 counters[group] = this._quantDuration; | 853 counters[group] = this._quantDuration; |
848 this._callback(counters); | 854 this._callback(counters); |
849 interval -= this._quantDuration; | 855 interval -= this._quantDuration; |
850 } | 856 } |
851 this._counters = []; | 857 this._counters = []; |
852 this._counters[group] = interval; | 858 this._counters[group] = interval; |
853 this._lastTime = time; | 859 this._lastTime = time; |
854 this._remainder = this._quantDuration - interval; | 860 this._remainder = this._quantDuration - interval; |
855 } | 861 } |
856 } | 862 } |
OLD | NEW |