|Re: [AD] use double for al_current_time and al_rest?|
[ Thread Index |
| More lists.liballeg.org/allegro-developers Archives
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] use double for al_current_time and al_rest?
- From: "Ryan Dickie" <goalieca@xxxxxxxxxx>
- Date: Sun, 20 Jan 2008 15:19:24 -0800
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:
I get a timer of 62.5 Hz, if I do:
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 <
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
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 . 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.