[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettimeofday() and clock

Francesco Orsenigo wrote:
> I wrote some timer code using gettimeofday(), as it seems to me the only 
> linux `standard` way to obtain non-blocking subsecond precision.

It's not the *only* way - but it's probably the best/most-portable.

> However i find that the tv_usec field increases by 10000 per second instead 
> of 1000.

Eh?  usec is short for MICROSECOND (a millionth of a second).

> May this depend on the CPU? (k7 850Mhz)

No - the value it returns is always in microseconds - but the resolution
might depend on the CPU.  On modern CPU's, you really do see it change in
millionth of a second steps - but on some (like DEC Alpha's) would only
increase the number in steps of 1000 or so.  However, the result was still
in microseconds - it just jumped in value instead of changing smoothly.

> Is possible to know the number of usecs ('u' stands for `micro`?) per second 
> without calling other timing functions?

Use gettimeofday - it's working just fine - you must have some other problem.

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
        http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
        http://prettypoly.sf.net http://freeglut.sf.net
        http://toobular.sf.net   http://lodestone.sf.net