Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access chrome profiling programmatically

Looking for some chrome API (to be used in chrome extension) that let me to do following programmatically:- - start profiling - end profiling - get list of time taken by all JS on the page

I can achieve the same in Firefox as:

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
}

Even some API that can let me to export the profiling info from developer tool bar will be helpful

like image 443
x64 Avatar asked Aug 08 '12 09:08

x64


1 Answers

You can profile a script in google chrome programmatically using the following code

console.profile("MyProfile");
// Enter name of script here
console.profileEnd();

"MyProfile" is the name of the profile which will be created.

Source:

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

You could get the time for a function / code snippet to execute by using a combination of console.time()and console.timeEnd()

like image 80
Binaromong Avatar answered Oct 24 '22 17:10

Binaromong