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

RE: Question about timing




On 07-Apr-2000 Mads Bondo Dydensborg wrote:
> I know this has been discussed recently, but I can't find it in my
> archive: What is the preferred way to obtain precise time?
> 
> I have looked at the following calls:
> 
> a) time(2) gets time in seconds
> b) gettimeofday(2) get time in seconds and microseconds
> c) clock(3) get time in processor ticks
> 
> a) is not precise enough for me.

(a) sucks for games

> b) is precise enough - but is there a large overhead in using this?

(b) is almost no overhead, but is not present in lesser os's. It's available
on SysV and BSD systems, but not windows or macs. It's accuracy is actually
chunks of 10 microseconds, but it accesses it as microsecond accuracy in case
we make machines fast enough to care... :) For my linux-only game, I'm using
this method, but it lacks portability

> c) is precise enough (I think) - but I am worried about portability and
>    overrun. And, this is only for my process, correct?
> 

It is spec'd as measuring time since the beginning of the program. It's the one
I suggest if you just want to normalize game time, so it doesn't run too fast
to play on some machines and too slow to play on others. I'm not sure what you
need precise time for, if you need a precise real world date/time, then this
function may not be suitable. If you just need to know how long a frame took to
render or something, this is probably the easiest and most portable way to do
it. 

> So, have I overlooked some? What is your recommendations? 
> 

yeah, you've overlooked some, but they're not very important :) I wrote a small
lame tutorial that might be what you're looking for, it's been waiting for the
new site to get into place... if you wanna look over it, it's at
http://math.smsu.edu/~br0ke/gamedev/timer/. It's probably nothing new since
you've already looked at the functions...

> Thanks,
> 
> Mads
> 
> -- 
> Mads Bondo Dydensborg.                               madsdyd@challenge.dk
> The Microsoft Dictionary
> 
>      security: Asks for a password. Example: Windows 95 has a high 
>                level of security because it asks for a password.
> 
> 

        -Erik <erik@smluc.org> [http://math.smsu.edu/~br0ke]

The opinions expressed by me are not necessarily opinions. In all
probability, they are random rambling, and to be ignored. Failure to ignore
may result in severe boredom or confusion. Shake well before opening. Keep
Refrigerated.
        

---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: linuxgames-help@sunsite.auc.dk