如何以编程方式访问chrome性能分析

x64*_*x64 11 javascript profiling google-chrome google-chrome-extension google-chrome-devtools

寻找一些chrome API(用于chrome扩展),让我以编程方式执行以下操作: - 开始分析 - 结束分析 - 获取页面上所有JS所用的时间列表

我可以在Firefox中实现同样的目标:

jsd = DebuggerService.getService(jsdIDebuggerService)
// start the profiling as
jsd.flags |= COLLECT_PROFILE_DATA;

// stop the profilinf as
jsd.flags &= ~COLLECT_PROFILE_DATA;

// get the details of how much time each JS function took
jsd.enumerateScripts({enumerateScript: function(script)
{
// script object has timings detail
}
Run Code Online (Sandbox Code Playgroud)

甚至一些可以让我从开发人员工具栏导出分析信息的API也会有所帮助

Bin*_*ong 10

您可以使用以下代码以编程方式在Google Chrome中配置脚本

console.profile("MyProfile");
// Enter name of script here
console.profileEnd();
Run Code Online (Sandbox Code Playgroud)

"MyProfile"是将要创建的配置文件的名称.

资源:

http://blog.codestars.eu/2011/profiling-with-webkit/

你可以得到时间的函数/代码片段通过使用组合执行console.time()console.timeEnd()

  • console.profiles() 似乎并不实际存在? (2认同)