api for reading cpu profiles from javascript

288 views
Skip to first unread message

Alvaro Pinot

unread,
Apr 15, 2016, 9:13:10 AM4/15/16
to Google Chrome Developer Tools
Is there any way of getting the cpu / heap profiles recording from the console?

I mean, after the execution of console.profile('foo'); console.profileEnd('foo')

Maybe something like console.profiles[0] or console.getProfiles()


Thanks in advance.

Pavel Feldman

unread,
Apr 15, 2016, 12:20:07 PM4/15/16
to Google Chrome Developer Tools
console.* methods do not return values by convention. If you want to programmatically process the profile, you could implement a Chrome extension that uses chrome.debugger extensions API. That extension would issue Profoler.enable method and as a result, upon each console.profile(End), the profile data would be delivered to the extension. Should be a dozen of lines altogether. See examples of how to attach to the page using that API. Note that DevTools for that tab needs to stay closed. You can use Runtime.evaluate command to script the page.

Pavel

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/1afc2452-cc40-4a46-9f6c-4e7872792bfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul Irish

unread,
Apr 15, 2016, 1:56:59 PM4/15/16
to Google Chrome Developer Tools

Alvaro Pinot

unread,
Apr 19, 2016, 3:30:29 AM4/19/16
to Google Chrome Developer Tools
Thank you! But the original idea is to profile a page without any extension :D


El viernes, 15 de abril de 2016, 18:20:07 (UTC+2), pfeldman escribió:
console.* methods do not return values by convention. If you want to programmatically process the profile, you could implement a Chrome extension that uses chrome.debugger extensions API. That extension would issue Profoler.enable method and as a result, upon each console.profile(End), the profile data would be delivered to the extension. Should be a dozen of lines altogether. See examples of how to attach to the page using that API. Note that DevTools for that tab needs to stay closed. You can use Runtime.evaluate command to script the page.

Pavel
On Fri, Apr 15, 2016, 08:13 Alvaro Pinot <alv...@neatnait.com> wrote:
Is there any way of getting the cpu / heap profiles recording from the console?

I mean, after the execution of console.profile('foo'); console.profileEnd('foo')

Maybe something like console.profiles[0] or console.getProfiles()


Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

Alvaro Pinot

unread,
Apr 19, 2016, 3:31:24 AM4/19/16
to Google Chrome Developer Tools
Than you Pau. That's, indeed, just what I was looking for :D 


El viernes, 15 de abril de 2016, 19:56:59 (UTC+2), Paul Irish escribió:

To add on, the https://github.com/paulirish/automated-chrome-profiling repo has a few recipes for this that should help.

On Apr 15, 2016 12:20 PM, "Pavel Feldman" <pfel...@chromium.org> wrote:
console.* methods do not return values by convention. If you want to programmatically process the profile, you could implement a Chrome extension that uses chrome.debugger extensions API. That extension would issue Profoler.enable method and as a result, upon each console.profile(End), the profile data would be delivered to the extension. Should be a dozen of lines altogether. See examples of how to attach to the page using that API. Note that DevTools for that tab needs to stay closed. You can use Runtime.evaluate command to script the page.

Pavel
On Fri, Apr 15, 2016, 08:13 Alvaro Pinot <alv...@neatnait.com> wrote:
Is there any way of getting the cpu / heap profiles recording from the console?

I mean, after the execution of console.profile('foo'); console.profileEnd('foo')

Maybe something like console.profiles[0] or console.getProfiles()


Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages