Search code examples
javascriptgoogle-chromegoogle-chrome-devtoolscpuprofiler

Percentages in CPU profiler in Chrome


What do the percentages in the chrome cpu profiler for the "Heavy (Bottom Up)" view indicate? Specifically I mean in the "Total" column. I had thought percentage of total cpu time (as in total cpu time over the course of the profile recording) but if this is the case then the numbers don't make sense to me since the total amount of cpu percentage time added up is greater than 100 in some cases for me. Does it mean rather the percentage of total cpu time in the function call alone? If so how does that make sense? Or does it possibly indicate only cpu time on a single core and thus having multiple cores will return percentages with a sum greater than 100?

Thanks!


Solution

  • Inclusive times don't add up to 100%, they exceed it, so don't add them up. Suppose you have routine A that calls B, and B that calls C, and so on through D, E, F, and finally to G that actually cranks the CPU for 100% of the time. Then F has 100% inclusive time, and so does E, D, on up to A.

    Inclusive time is far more useful to know than self time, 1) because it includes self time, and 2) because the problem could very well be in any one of those routines, not just G.

    Therefore it gives you more places to look for speedups, with the result that you find more.