[uClibc] clock() for long-running process
Manuel Novoa III
mjn3 at codepoet.org
Mon May 10 17:00:21 UTC 2004
On Sun, May 09, 2004 at 03:41:23PM +0200, Joakim Tjernlund wrote:
> > mjn3> Besides, you really shouldn't be using clock() to calculate
> > mjn3> elapsed cpu time when times() is available. The X/Open System
> > mjn3> Interfaces Extension mandates that clock() values be scaled to
> > mjn3> millionths of a second, which limits its usefulness on 32 bit
> > mjn3> systems for long-running apps.
> >
> > I agree. But I think there are many programs using two clock() call
> > to calclate elapsed time ...
>
> hmm, times() returns a clock_t type which is signed. How
> should one use times() to calc. elapsed time?
> Just type cast its return value to an unsigned long?
When I wrote that times() should be used, I meant as it is used by
clock() but without the scaling. clock() measures cpu time used by
the process and calculates that by adding the tms_utime and tms_stime
fields of the struct tms set by times(). Best done with a custom
wrapper function that doesn't do the CLOCKS_PER_SECOND scaling that
clock() has to do.
Manuel
More information about the uClibc
mailing list