J.A. Magallon wrote: >On 2002.04.30 Wanghong Yuan wrote: > >>Is there any package or program, which can be used to accurately measure the >>CPU cycles used by a program? I think the following code can only provide an >>inaccurate one, beause it may count on the waiting time of the program. >> >>gettimeofday(t1) >>runprogam >>gettimeofday(t2) >>t2-t1 >> >>If I need to instrument the kernel, which part I should investigate? Thanks >>a lot in advance >> > >man getrusage > getrusage is grossly inaccurate. If a process is running when the timer interrupt hits, it's assigned an entire timer interrupt's worth of CPU, even if it's only run one instruction. I've attached an old patch that makes getrusage farily accurate. It's not going to be accurate to the CPU cycle, but it's not too bad. It does increase the overhead for system calls and interrupts. It works on newer x86 and PowerPC. -Corey