Android – How to get the accurate CPU Usage per process and process Idle CPU Time

androidjava-native-interfacelinuxoperating system

I'hv been struggling to get the accurate CPU Usage per process and process Idle CPU Time..
I tried " top " command proc/[pid]/stat folder but still trying my luck..

TOP command gives CPU usage for all the processes running in fg(foreground) and bg(background)
but it is not as accurate i feel.. because it shows %CPU 0, even if the process is running in the background.. Any other way? please help

Best Answer

I have found a way to do it myself.. I am using

  1. proc/[pid]/stat -> for per process CPU Usage 14th and 15th parameter
  2. proc/stat -> for All processes CPU consumption at the same time