| 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 /** | 6 /** |
| 7 * @constructor | 7 * @constructor |
| 8 * @param {!ProfilerAgent.CPUProfile} profile | 8 * @param {!ProfilerAgent.CPUProfile} profile |
| 9 */ | 9 */ |
| 10 WebInspector.CPUProfileDataModel = function(profile) | 10 WebInspector.CPUProfileDataModel = function(profile) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 */ | 33 */ |
| 34 _calculateTimes: function(profile) | 34 _calculateTimes: function(profile) |
| 35 { | 35 { |
| 36 function totalHitCount(node) { | 36 function totalHitCount(node) { |
| 37 var result = node.hitCount; | 37 var result = node.hitCount; |
| 38 for (var i = 0; i < node.children.length; i++) | 38 for (var i = 0; i < node.children.length; i++) |
| 39 result += totalHitCount(node.children[i]); | 39 result += totalHitCount(node.children[i]); |
| 40 return result; | 40 return result; |
| 41 } | 41 } |
| 42 profile.totalHitCount = totalHitCount(profile.head); | 42 profile.totalHitCount = totalHitCount(profile.head); |
| 43 this.totalHitCount = profile.totalHitCount; |
| 43 | 44 |
| 44 var duration = this.profileEndTime - this.profileStartTime; | 45 var duration = this.profileEndTime - this.profileStartTime; |
| 45 var samplingInterval = duration / profile.totalHitCount; | 46 var samplingInterval = duration / profile.totalHitCount; |
| 46 this.samplingInterval = samplingInterval; | 47 this.samplingInterval = samplingInterval; |
| 47 | 48 |
| 48 function calculateTimesForNode(node) { | 49 function calculateTimesForNode(node) { |
| 49 node.selfTime = node.hitCount * samplingInterval; | 50 node.selfTime = node.hitCount * samplingInterval; |
| 50 var totalHitCount = node.hitCount; | 51 var totalHitCount = node.hitCount; |
| 51 for (var i = 0; i < node.children.length; i++) | 52 for (var i = 0; i < node.children.length; i++) |
| 52 totalHitCount += calculateTimesForNode(node.children[i]); | 53 totalHitCount += calculateTimesForNode(node.children[i]); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 /** | 398 /** |
| 398 * @param {number} index | 399 * @param {number} index |
| 399 * @return {!ProfilerAgent.CPUProfileNode} | 400 * @return {!ProfilerAgent.CPUProfileNode} |
| 400 */ | 401 */ |
| 401 nodeByIndex: function(index) | 402 nodeByIndex: function(index) |
| 402 { | 403 { |
| 403 return this._idToNode[this.samples[index]]; | 404 return this._idToNode[this.samples[index]]; |
| 404 } | 405 } |
| 405 | 406 |
| 406 } | 407 } |
| OLD | NEW |