Take a look at ps
command. It has format specifiers, i.e. fields/columns that provide CPU and wall time.
For example cputime for Android:
ps -x
will yield something that looks like this
u0_a16 18214 17002 743644 18104 ffffffff 00000000 S com.android.location.fused (u:10, s:13)
where u:10 and s:13 stand for time the CPU has spent on the processes (source : http://codeseekah.com/2012/10/21/android-shell-tricks-ps/)
I've made a Linux script for collecting system stats which you can check here: https://gist.github.com/izmailoff/8923008.