Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Is your question restricted to shell use -- or would other options be helpful as well? – Izzy Sep 27 '12 at 12:53

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.

share|improve this answer

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.