I need to get the total cpu time of a process in android. I am trying to use adb shell top commands, but it gives only cpu usage in terms of percentage.

But I need the total cpu time of the process. I can get this info in my Ubuntu, but I could not find a way to get the TIME+ column in android.

Any suggestions?

  • Is your question restricted to shell use -- or would other options be helpful as well?
    – Izzy
    Sep 27, 2012 at 12:53

2 Answers 2


You didn't mention which version of Android you are running, but I believe this will work in most modern versions. The exact location within the settings may change depending on version and device manufacturer.

If you go in to Settings -> Battery and then select an app, you get some or all of the following details:

  • CPU total time in seconds
  • Keep awake time in seconds
  • Data send
  • Data received

I believe these details are valid from the last time the device booted.


This little shell script I just wrote should work. It parses /proc/<PID>/stat.


if [ $# -ne 1 ]
    echo "Please provide a PID"
    exit 0

line=$(sed 's|.*) ||' $stat)
utime=$(echo $line | awk '{print $12}')
stime=$(echo $line | awk '{print $13}')
cputime=$((10 * $stime + $utime))
echo $cputime # milliseconds
  • I am a noob in adb, so help me how to run this. I used cat > cpuinfo to create this as a file but can't run it because permission denied. chmod u+x cpuinfo tells me Operation not permitted. Out of luck on non-rooted phone?
    – Vitas
    Jan 9, 2017 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .