Something weird with Sys.getTimerResolution()?

For some time I’ve seen that in my emulator, on some machines it runs the MSX part way too fast. It doesn’t happen on all computers, only just a few.
The FPS counter shows 50 fps, while in reality it’s much faster. It turned out the timing was being screwed up somehow.
I’ve been able to fix the problem, by removing the calls to Sys.getTimerResolution() in each frame and only call that at initialization.

Now for the weird stuff:

  1. This happens since java5, in 1.4.2 it still works correctly (even though Sys.getTimerResolution() is an LWJGL call).
  2. I thought that maybe it has something to do with http://support.microsoft.com/?id=821893, so I looked in the LWJGL source to see what api Sys.getTimerResolution uses. It seems to simply return a fixed value of 1000. (All this is on windows, still using lwjgl 0.99)

I’m sure I’ve made a mistake somewhere in my asesment of the situation, but right know I just have no idea what, and why my change (removing the Sys.getTimerResolution call out of the loop) fixed my problem.

Any ideas?

That is indeed very weird - I can only think of some kind of int/long->float/double rounding problem in the timer calculation. You could try and make the relevant code strictfp and see if behaves the same in 1.4.2 and 1.5.

  • elias