aslushnikov / tracium

A blessed Chrome Trace parser.
Apache License 2.0
72 stars 7 forks source link

Capture CPU % usage? #17

Open Nithanaroy opened 3 years ago

Nithanaroy commented 3 years ago

Is it possible to obtain the % of CPU being used from these traces?

Or in general, is there a way to programmatically get the % of CPU being used at any given instance? By % of CPU used I mean the value something like shown in task manager of Chrome.

Thank you :)

patrickhulce commented 3 years ago

CPU % usage for a single thread env like JS main thread is just dependent on your time window :) the trace tells you when something is being executed and you can interpret that however you'd like.

If you wanted something more hands off, Performance.getMetrics might be more interesting to you which powers the "CPU %" graph in Chrome DevTools (see https://source.chromium.org/chromium/chromium/src/+/master:third_party/devtools-frontend/src/front_end/performance_monitor/PerformanceMonitor.js;l=498-502)

Nithanaroy commented 3 years ago

Thanks for the links @patrickhulce. So each plot in the CPU graph in the performance panel of dev tools is a normalized duration plot? While this is sufficient to compare the CPU usage of two algorithms, I still found it tricky to explain this difference to a colleague. I felt it would be easier to talk in terms of CPU % that commands like top or Chrome's Task Manager show. This might be a wrong place to ask, but is there a way get this type of CPU % in a scriptable manner either via dev tools protocol or in a browser extension env or some other way while staying in Chrome's runtime?

Thank you :)

kalpeshchilka commented 3 years ago

@Nithanaroy @patrickhulce Did you found any workaround to get this data or an actual solution. Please let me know, even I'm looking for similar data. I've also tried accessing the link - (https://source.chromium.org/chromium/chromium/src/+/master:third_party/devtools-frontend/src/front_end/performance_monitor/PerformanceMonitor.js;l=498-502) but seems does not exist anymore. Any workaround solution for this problem would be of great help! Thanks!