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

Re: Question about timing



> 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.
> b) is precise enough - but is there a large overhead in using this?
> c) is precise enough (I think) - but I am worried about portability and
>    overrun. And, this is only for my process, correct?
> 
> So, have I overlooked some? What is your recommendations? 

Use b. The overhead really isn't important: you'll be using it once
per frame and can then store the result. The overhead from rendering a
few thousand triangles or some bitmaps or whatever will FAR exceed the
overhead of that call.

Premature optimisation and all that.


Actually, gettimeofday() will probably just copy the two values out of
the system's store for them. It's just possible it calls clock() and
does some multiplying.

In all honesty, I use gettimeofday() and convert it to a floating
point repn of seconds and don't have any problems.



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