Originally Posted by towheedm
The simplest way I can think of is with top. It can be used for re-nicing a process while checking CPU usage at the same time. See 'man top' for it's usage.
Yes top commands TIME/TIME+ give the time a process has spent on the CPU. However I am using this in android and top dosen't have all the fields and dosen't support the interactive keys. What is the proper way to compile the top.c file. I tried to compile(on ubuntu) it gives lot of undefined errors.
Originally Posted by syg00
I might be inclined to retain the data in /proc/<pid>/stat at various time-points. You'll need to do the math yourself, but you can get the data (exactly) when you want it.
I looked in to the /proc/<pid>/stat and found a code to display the output in a more readable form
There are many time values what should I be looking for getting the processes time spent on CPU(or increase or decrease after a renice).
Also correct me if am wrong I should be trying to measure the time slices the process gets on each run, and try to see if there is an increase in the time slice or the frequency of getting the CPU has increased ryt? what fields in the /proc/stat should be used?
here is the out put,
# ./procstat 1142
start_time: 06.25 15:24 (2698.61s)