[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettimeofday() and clock
- To: linuxgames@sunsite.dk
- Subject: Re: gettimeofday() and clock
- From: Steve Baker <sjbaker1@airmail.net>
- Date: Sun, 25 Aug 2002 16:39:55 -0500
- Delivered-To: archiver@seul.org
- Delivered-To: mailing list linuxgames@sunsite.dk
- Delivery-Date: Sun, 25 Aug 2002 17:39:03 -0400
- Mailing-List: contact linuxgames-help@sunsite.dk; run by ezmlm
- Organization: Steve at Home
- References: <20020825181949.7BB633722@gate.home.lan>
- Reply-To: linuxgames@sunsite.dk
- 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 : <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