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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 layerTree.setLayers(rootLayer, callback.bind(null, layerTree)); | 373 layerTree.setLayers(rootLayer, callback.bind(null, layerTree)); |
374 } | 374 } |
375 }, | 375 }, |
376 | 376 |
377 __proto__: WebInspector.DeferredLayerTree.prototype | 377 __proto__: WebInspector.DeferredLayerTree.prototype |
378 }; | 378 }; |
379 | 379 |
380 | 380 |
381 /** | 381 /** |
382 * @constructor | 382 * @constructor |
383 * @param {!Array.<!WebInspector.TimelineFrame>} frames | |
384 */ | |
385 WebInspector.FrameStatistics = function(frames) | |
386 { | |
387 this.frameCount = frames.length; | |
388 this.minDuration = Infinity; | |
389 this.maxDuration = 0; | |
390 this.timeByCategory = {}; | |
391 this.startOffset = frames[0].startTimeOffset; | |
392 var lastFrame = frames[this.frameCount - 1]; | |
393 this.endOffset = lastFrame.startTimeOffset + lastFrame.duration; | |
394 | |
395 var totalDuration = 0; | |
396 var sumOfSquares = 0; | |
397 for (var i = 0; i < this.frameCount; ++i) { | |
398 var duration = frames[i].duration; | |
399 totalDuration += duration; | |
400 sumOfSquares += duration * duration; | |
401 this.minDuration = Math.min(this.minDuration, duration); | |
402 this.maxDuration = Math.max(this.maxDuration, duration); | |
403 WebInspector.FrameStatistics._aggregateTimeByCategory(this.timeByCategor
y, frames[i].timeByCategory); | |
404 } | |
405 this.average = totalDuration / this.frameCount; | |
406 var variance = sumOfSquares / this.frameCount - this.average * this.average; | |
407 this.stddev = Math.sqrt(variance); | |
408 } | |
409 | |
410 /** | |
411 * @param {!Object} total | |
412 * @param {!Object} addend | |
413 */ | |
414 WebInspector.FrameStatistics._aggregateTimeByCategory = function(total, addend) | |
415 { | |
416 for (var category in addend) | |
417 total[category] = (total[category] || 0) + addend[category]; | |
418 } | |
419 | |
420 /** | |
421 * @constructor | |
422 * @param {number} startTime | 383 * @param {number} startTime |
423 * @param {number} startTimeOffset | 384 * @param {number} startTimeOffset |
424 */ | 385 */ |
425 WebInspector.TimelineFrame = function(startTime, startTimeOffset) | 386 WebInspector.TimelineFrame = function(startTime, startTimeOffset) |
426 { | 387 { |
427 this.startTime = startTime; | 388 this.startTime = startTime; |
428 this.startTimeOffset = startTimeOffset; | 389 this.startTimeOffset = startTimeOffset; |
429 this.endTime = this.startTime; | 390 this.endTime = this.startTime; |
430 this.duration = 0; | 391 this.duration = 0; |
431 this.timeByCategory = {}; | 392 this.timeByCategory = {}; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 /** | 486 /** |
526 * @constructor | 487 * @constructor |
527 */ | 488 */ |
528 WebInspector.PendingFrame = function() | 489 WebInspector.PendingFrame = function() |
529 { | 490 { |
530 /** @type {!Object.<string, number>} */ | 491 /** @type {!Object.<string, number>} */ |
531 this.timeByCategory = {}; | 492 this.timeByCategory = {}; |
532 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ | 493 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ |
533 this.paints = []; | 494 this.paints = []; |
534 } | 495 } |
OLD | NEW |