CPU Time of a process in android

android, cpu, process, shell

Solution

I'm not sure if this would work on a non-rooted device, but:

echo $(adb shell ps | grep com.android.phone | awk '{ system("adb shell cat /proc/" $2 "/stat");}' | awk '{print $14+$15;}')

This would print the sum of the user mode jiffies and kernel mode jiffies used by the process. Replace com.android.phone with the name of the process you're interested in.

Problem

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?

Original source