Subject: Re: process execution time
To: None <brook@biology.nmsu.edu>
From: Charles Swiger <cswiger@mac.com>
List: netbsd-help
Date: 10/01/2004 15:43:01
On Oct 1, 2004, at 1:42 PM, brook@biology.nmsu.edu wrote:
> One of my students is trying to measure the execution time of
> processes and has tried a number of ways, including getrusage(),
> gettimeofday(), and clock().  It appears that at certain times two
> consecutive calls to these functions suggest that the clock is not
> monotonically increasing.  Can this really be the case?

Sure.  Clocks tick on a regular basis and update their associated 
counter on a periodic basis.  However, if you ask "what time is it?" 
twice during a tick, you'll get the same answer.

If you are running ntpd, things can become more complicated, although 
ntpd will normally attempt to skew rather than step the time.

> How should one profile the execution time of parts of programs?

Compile the program for profiling.  See "man gprof".

-- 
-Chuck