简体   繁体   English

Chrome Web检查器:CPU分析器

[英]Chrome web inspector : CPU profiler

在此处输入图片说明

My program takes about 20 sec to load (lot of svg objects). 我的程序需要大约20秒的加载时间(很多svg对象)。 I am trying to profile using chrome web inspector. 我正在尝试使用Chrome Web检查器进行配置文件。 It shows a total of 19.16 sec, but the breakdown doesn't quite add up. 它总共显示了19.16秒,但故障并没有完全累加。 I tried bottom up, top down and sorted in different combination. 我尝试自下而上,自上而下并以不同的组合进行排序。 Still cannot identify the bottle neck. 仍无法识别瓶颈。 I could see the data receive within few milliseconds from server, but takes long to render it. 我可以看到数据在几毫秒内从服务器接收到,但是渲染它需要很长时间。

Also in the %ge view, the total is 98%, but the rest is less than 0.05% individually and doesn't seems right. 同样在%ge视图中,总数为98%,但是其余的单独值都小于0.05%,这似乎并不正确。

In my previous qn , I asked how to show #calls and average. 在上一个qn中 ,我问如何显示#calls和平均值。 I doubt a recursive call may cause this, but at the same time the total time should reflect that. 我怀疑递归调用可能会导致这种情况,但同时总时间应该反映出这一点。

在此处输入图片说明 How can I identify the function which causes this delay. 如何确定导致此延迟的功能。 Any help appreciated. 任何帮助表示赞赏。

You can use this function to log time differences between calls: 您可以使用此功能记录呼叫之间的时间差:

var timeVal = new Date().getTime();
var log = function(name){
    var str = new Date().toLocaleTimeString();
    var newTime = new Date().getTime();
    str += " (" + (newTime - timeVal) + "ms)";
    timeVal = newTime;
    console.log(str, name)
}

Use it like this: 像这样使用它:

log("prepare for something")
// do something
log("something happened");

Output: 输出:

16:57:46 (2496ms) prepare for something
16:57:46 (130ms) something happened

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM