admin管理员组文章数量:1022997
I'm wondering is there any (un)official spec to .cpuprofile file format, which is generated when JavaScript profiling is used in Chromium-based browser's developer tools.
It is plain-text JSON so it is easy to get call tree data but I don't understand how to get timing information for each function.
Also I'm interested in hit count for every function.
I'm wondering is there any (un)official spec to .cpuprofile file format, which is generated when JavaScript profiling is used in Chromium-based browser's developer tools.
It is plain-text JSON so it is easy to get call tree data but I don't understand how to get timing information for each function.
Also I'm interested in hit count for every function.
Share Improve this question asked Nov 17, 2014 at 20:16 OlegasOlegas 10.5k8 gold badges55 silver badges74 bronze badges 3- 1 Have a look at google-perftools.googlecode./svn/trunk/doc/cpuprofile.html and google-perftools.googlecode./svn/trunk/doc/… – artm Commented Nov 20, 2014 at 10:23
- Were you ever able to figure out how to get the timing information directly from the json file? – CorrugatedAir Commented May 7, 2016 at 13:39
- 2 Updated link for @artm docs on github (via rawgit) cdn.rawgit./gperftools/gperftools/master/docs/… and cdn.rawgit./gperftools/gperftools/master/docs/… however these links discuss a binary file format not the JSON one – Colin D Commented Dec 22, 2016 at 20:49
3 Answers
Reset to default 2According to the documentation provided by @artm, the output can be analyzed with kcachegrind. What you need to do in order to load a Chrome .cpuprofile file into this is to convert it to callgrind format.
You don't mention your dev environment, so I can't say the best what the easiest way for you to go about this will be.
The documentation mentions Google's perf tools and kcachegrind for this. These tools need to be built manually and I don't have a convenient environment for doing that.
Here is how I went about it on a Windows 8.1 machine with Node installed.
Install chrome2calltree for Node. This mand utility will convert your .cpuprofile to a callgrind format.
Install QCacheGrind. This is a Windows pre-built port of kcachegrind that will let you visualize your callgrind formatted file.
Convert your .cpuprofile:
chrome2calltree -i test.cpuprofile -o callgrind.profile
Open your callgrind.profile with QCacheGrind.
Maybe it is notable but the JSON format of cpuprofile probably has changed recently, so it may not be a stable format. In Chromium 44 for example (older version from their build archives) it looked like this
jq keys < chromium_44.cpuprofile
[
"endTime",
"head",
"samples",
"startTime",
"timestamps"
]
In latest chrome 55 it is
jq keys < chrome_55.cpuprofile
[
"endTime",
"nodes",
"samples",
"startTime",
"timeDeltas"
]
Just something to be wary of. I have not seen much if any documentation on the format though
This might not be a direct answer to your question , but this is really awesome.
usage is very simple:
fireunit.profile(function(){
document.getElementsByClassName("foo");
});
You’ll get the following JavaScript object returned from fireunit.getProfile():
{
"time": 8.443,
"calls": 611,
"data":[
{
"name":"makeArray()",
"calls":1,
"percent":23.58,
"ownTime":1.991,
"time":1.991,
"avgTime":1.991,
"minTime":1.991,
"maxTime":1.991,
"fileName":"jquery.js (line 2059)"
},
// etc.
]}
I'm wondering is there any (un)official spec to .cpuprofile file format, which is generated when JavaScript profiling is used in Chromium-based browser's developer tools.
It is plain-text JSON so it is easy to get call tree data but I don't understand how to get timing information for each function.
Also I'm interested in hit count for every function.
I'm wondering is there any (un)official spec to .cpuprofile file format, which is generated when JavaScript profiling is used in Chromium-based browser's developer tools.
It is plain-text JSON so it is easy to get call tree data but I don't understand how to get timing information for each function.
Also I'm interested in hit count for every function.
Share Improve this question asked Nov 17, 2014 at 20:16 OlegasOlegas 10.5k8 gold badges55 silver badges74 bronze badges 3- 1 Have a look at google-perftools.googlecode./svn/trunk/doc/cpuprofile.html and google-perftools.googlecode./svn/trunk/doc/… – artm Commented Nov 20, 2014 at 10:23
- Were you ever able to figure out how to get the timing information directly from the json file? – CorrugatedAir Commented May 7, 2016 at 13:39
- 2 Updated link for @artm docs on github (via rawgit) cdn.rawgit./gperftools/gperftools/master/docs/… and cdn.rawgit./gperftools/gperftools/master/docs/… however these links discuss a binary file format not the JSON one – Colin D Commented Dec 22, 2016 at 20:49
3 Answers
Reset to default 2According to the documentation provided by @artm, the output can be analyzed with kcachegrind. What you need to do in order to load a Chrome .cpuprofile file into this is to convert it to callgrind format.
You don't mention your dev environment, so I can't say the best what the easiest way for you to go about this will be.
The documentation mentions Google's perf tools and kcachegrind for this. These tools need to be built manually and I don't have a convenient environment for doing that.
Here is how I went about it on a Windows 8.1 machine with Node installed.
Install chrome2calltree for Node. This mand utility will convert your .cpuprofile to a callgrind format.
Install QCacheGrind. This is a Windows pre-built port of kcachegrind that will let you visualize your callgrind formatted file.
Convert your .cpuprofile:
chrome2calltree -i test.cpuprofile -o callgrind.profile
Open your callgrind.profile with QCacheGrind.
Maybe it is notable but the JSON format of cpuprofile probably has changed recently, so it may not be a stable format. In Chromium 44 for example (older version from their build archives) it looked like this
jq keys < chromium_44.cpuprofile
[
"endTime",
"head",
"samples",
"startTime",
"timestamps"
]
In latest chrome 55 it is
jq keys < chrome_55.cpuprofile
[
"endTime",
"nodes",
"samples",
"startTime",
"timeDeltas"
]
Just something to be wary of. I have not seen much if any documentation on the format though
This might not be a direct answer to your question , but this is really awesome.
usage is very simple:
fireunit.profile(function(){
document.getElementsByClassName("foo");
});
You’ll get the following JavaScript object returned from fireunit.getProfile():
{
"time": 8.443,
"calls": 611,
"data":[
{
"name":"makeArray()",
"calls":1,
"percent":23.58,
"ownTime":1.991,
"time":1.991,
"avgTime":1.991,
"minTime":1.991,
"maxTime":1.991,
"fileName":"jquery.js (line 2059)"
},
// etc.
]}
本文标签: javascriptGoogle Chrome developer toolsProfiling results file formatStack Overflow
版权声明:本文标题:javascript - Google Chrome developer tools - Profiling results file format - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745525076a2154487.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论