What Is "cpu Time" (using Android's Ps -x)?
So I'm trying to write a Java function that gathers CPU time for processes, and compares them to prior readings to determine the CPU time a process has demanded since the last samp
Solution 1:
The values are CPU and system time in clock ticks. The definition can be found in the man 5 proc
text from a desktop system:
utime %lu Amount of time that this process has been scheduled
in user mode, measured inclock ticks (divide by
sysconf(_SC_CLK_TCK). This includes guest time,
guest_time (time spent running a virtual CPU, see
below), so that applications that are not aware of
the guest time field donot lose that time from
their calculations.
stime %lu Amount of time that this process has been scheduled
in kernel mode, measured inclock ticks (divide by
sysconf(_SC_CLK_TCK).
The values are tracked per-thread, so you should be using ps -t -x
to see all threads in each process. Without -t
you're just looking at the stats for the main thread, which may be why your numbers don't add up.
Post a Comment for "What Is "cpu Time" (using Android's Ps -x)?"