High-resolution user/system times?
Baruch Even
baruch at ev-en.org
Wed Jul 25 10:35:54 IDT 2012
On Wed, Jul 25, 2012 at 10:09 AM, Nadav Har'El <nyh at math.technion.ac.il> wrote:
> Hi, as you know the time(1) command, and the times(2) system call is
> able to separate a process's running time into "user" and "system" time,
> measuring the CPU time in user space and kernel space respectively.
>
> However, these only have a jiffy (often 1/250 seconds) resultion.
>
> I'm now trying to measure a process running around 3 milliseconds, less
> than one jiffy, and I still want to understand how much of it is spent in
> user space, and how much of it is spent in kernel space (e.g., handling on
> minor page faults caused by this process). Does anybody have any idea what I
> can use to do that, preferably without modifying the Linux kernel?
You could try to post-process the output of strace -tt -T <cmd>
The times strace provide are fairly accurate but it does change the
process a bit (switching to the tracing process for any system call).
An alternative could be to use systemtap to collect the information
with less impact. systemtap lets you define a tracing logic for the
kernel, it will generate a kernel module implementing this logic that
you can load into the kernel. It still has impact but less than the
context switch to another process.
Baruch
More information about the Linux-il
mailing list