Search code examples
androidlinuxprofilingperf

Perf doesn't add up to 100%


I am trying to measure the cpu usage of my Android mobile phone using perf tool. Since my phone (Redmi Note 3) doesn't have perf tool. I used simpleperf tool provided by google. I recorded system wide cpu usage using perf record -e cpu-cycles -a. The cpu usage overhead reported by perf must add to 100% but cpu usage report I got from my phone only adds up to 12% after 10 minutes of profiling. I profiled while putting my phone on idle with all applications killed.

And also when I profiled for 1 minute it added to about 70%.

Is it abnormal? or doesn't perf report idle time of cpu so I only have 12% of cpu usage left?


Solution

  • I found out that it is because of floating point (precision) error in perf. Since perf only calculates overhead upto 0.0x% percision when I run perf record for long enough even with overhead less than 0.01% pile up and after 30 min they add upto about 50% so the overhead reported will only sum up to 50% as rest 50% is from 0.00x% which is rounded down to 0.00%.