Quote:
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.
Quote:
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
pid: 1142
tcomm: (com.test.noise3)
state: S
ppid: 37
pgid: 37
sid: 0
tty_nr: 0
tty_pgrp: -1
flags: 4194624
min_flt: 6040
cmin_flt: 0
maj_flt: 0
cmaj_flt: 0
utime: 11.590000
stime: 7.790000
cutime: 0.000000
cstime: 0.000000
priority: 20
nice: 0
num_threads: 8
it_real_value: 0.000000
start_time: 06.25 15:24 (2698.61s)
vsize: 137080832
rss: 5090
rsslim: 4294967295
start_code: 32768
end_code: 36524
start_stack: 3199794400
esp: 3199793352
eip: 2949704456
pending: 0000000000000000
blocked: 0000000000001204
sigign: 0000000000000000
sigcatch: 00000000000094e8
wchan: 4294967295
zero1: 0
zero2: 0
exit_signal: 0000000000000011
cpu: 0
rt_priority: 0
policy: 0
#