Demo/bin/Debug/front_end/sdk/CPUProfileDataModel.js
(开头部分) 11KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @constructor
* @param {!ProfilerAgent.CPUProfile} profile
*/
WebInspector.CPUProfileDataModel = function(profile)
{
this.profileHead = profile.head;
this.samples = profile.samples;
this.timestamps = profile.timestamps;
this.profileStartTime = profile.startTime * 1000;
this.profileEndTime = profile.endTime * 1000;
this._assignParentsInProfile();
if (this.samples) {
this._normalizeTimestamps();
this._buildIdToNodeMap();
this._fixMissingSamples();
this._fixLineAndColumnNumbers();
}
this._calculateTimes(profile);
}
WebInspector.CPUProfileDataModel.prototype = {
/**
* @param {!ProfilerAgent.CPUProfile} profile
*/
_calculateTimes: function(profile)
{
function totalHitCount(node) {
var result = node.hitCount;
for (var i = 0; i < node.children.length; i++)
result += totalHitCount(node.children[i]);
return result;
}
profile.totalHitCount = totalHitCount(profile.head);
var duration = this.profileEndTime - this.profileStartTime;
var samplingInterval = duration / profile.totalHitCount;
this.samplingInterval = samplingInterval;
function calculateTimesForNode(node) {
node.selfTime = node.hitCount * samplingInterval;
var totalHitCount = node.hitCount;
for (var i = 0; i < node.children.length; i++)
totalHitCount += calculateTimesForNode(node.children[i]);
node.totalTime = totalHitCount * samplingInterval;
return totalHitCount;
}
calculateTimesForNode(profile.head);
},
_fixLineAndColumnNumbers: function()
{
var nodeListsToTraverse = [ this.profileHead.children ];
while (nodeListsToTraverse.length) {
var nodeList = nodeListsToTraverse.pop();
后面还有 253 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。