Timer module initialization and precision

Issue #303 resolved
Boolsheet
created an issue

== Dead variable The love:⏲:sdl::Timer class has an unsigned integer called time_init. It is set to 0 in the constructor and used as a subtrahend in Timer::getTime.

I believe its intended purpose was to offset the value SDL_GetTicks returns to 0 so love.timer.getTime always returns the seconds since initialization. SDL already takes care of that which makes time_init useless.

== Precision loss love.timer.getTime and love.timer.getMicroTime are affected by precision loss after 1.165 hours and 4.1943 seconds respectively. Switching from single precision to double precision floating-point numbers increases these numbers to more than a hundred years.

Of course that doesn't change the limitation by their time providers (around 49.71 days for SDL_GetTicks).

Comments (5)

  1. Boolsheet reporter

    Alright, that did it.

    I noticed the 24 hour limit on getMicroTime again. I take this chance and propose another API slaughter. The new gained precision gives us a hundred years, let's drop that silly limit! ;)

    Attached a patch which drops the 24h limit and suggests some optimizations for Windows. Also attached a script that tests the 2 functions in another way. It shows function name, current value, smallest difference of two subsequent calls and then the 20 largest differences. Example:

    love.timer.getMicroTime
    4214.455163662
       0.00000077 -- My system provides a resolution of 0.6 microseconds.
    
       0.00004345
       0.00003355
       0.00002355
       0.00001355
       0.00000445
       ...
    
  2. Log in to comment