[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettimeofday() and clock
- To: email@example.com
- Subject: Re: gettimeofday() and clock
- From: Steve Baker <firstname.lastname@example.org>
- Date: Sun, 25 Aug 2002 16:39:55 -0500
- Delivered-To: email@example.com
- Delivered-To: mailing list firstname.lastname@example.org
- Delivery-Date: Sun, 25 Aug 2002 17:39:03 -0400
- Mailing-List: contact email@example.com; run by ezmlm
- Organization: Steve at Home
- References: <20020825181949.7BB633722@gate.home.lan>
- Reply-To: firstname.lastname@example.org
- User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529
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 : <email@example.com> WorkMail: <firstname.lastname@example.org>
URLs : http://www.sjbaker.org
http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net