|
There are 3 times to consider:
1- The system times: the time spent by the kernel on behalf the process, that is: servicing system calls, doing thread related computations too in systems with native threads, page faults and so on.
2- The CPU times: the effective time spent by the process in the CPU. This is independent from system load.
3- The clock time: the total time spent from start to finish (what the user would notice anyway). It isn't precise as it depends on system load.
To get them you may use the getrusage() system call for #1 & #2 and gettimeofday() for #3, or times() to get them all. I prefer getrusage()/gettimeofday() because it has microsecond resolution.
PS: Depending on what you are trying to measure, you may use the sum of #1 and #2. Use #2 when you want to measure computations and #1 to measure system call overhead.
PS: Also, you may get rusage information for each child using wait3()/wait4()
Last edited by primo; 06-15-2006 at 01:59 AM.
|