Re: [AD] use double for al_current_time and al_rest?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Jan 20, 2008 9:41 AM, Elias Pschernig <elias@xxxxxxxxxx> wrote:
On Sat, 2007-12-29 at 23:34 +1100, Peter Wang wrote:
>
> That's horrible for multithreaded programs, unless the counter is
> thread-local.  Even then, it's horrible as soon as you have two time
> intervals to track within the one OS thread.  In any case, we use
> al_current_time() for the time stamp in events.  We need a global
> reference for that.

Ok, if nobody complains, I'll just change all the time related "long"
into uint64_t, and change from milliseconds to nanoseconds.

Milliseconds are really not enough, e.g. when I do:

al_set_timer_speed(16)

I get a timer of 62.5 Hz, if I do:

al_set_timer_speed(17)

I get a timer of 58.8 Hz. This is ridiculous, Allegro 4 was able to give
me an exact 60 Hz timer, and even in DOS or on ancient machines like a
C-64 it was possible :P

Allegro 5 *at least* would need us, but as we already would need
uint64_t for that, best is ns. (Or double, which I would still prefer,
but apparently there is concern about diminishing accuracy after a few
1000 years of continuously running the program..)

--
Elias Pschernig < elias@xxxxxxxxxx>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--
https://lists.sourceforge.net/lists/listinfo/alleg-developers

Floating is more natural to humans because in physics we use the reals. The only downside is the necessary conversion between floating and integer. Precision is not going to be an issue unless someone does something really remarkable like running continuously for 600 hours. Boost::timer uses floating point to measure time [1]. They claim they can measure an elapsed time of at least 596 hours across the various platforms. They estimate this in the user visible elapsed_max() function. This is very useful for timing things like how long it takes to complete a lap. It might also be interesting to add simple count up and countdown timer functions/structures.  These types of timers are probably best described in terms of floating point.

[1] http://www.boost.org/libs/timer/timer.htm

--
ryan


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/