The new LWJGL 0.96 timer on win32

I’m having problems with the new hires timer on windows. Try the following webstarable application too see how it runs on your computer:

http://home.halden.net/tombr/timertest/timertest.php

The queryPerformanceCounter has been replaced with timeGetTime. It is suposed to have a 1 ms resolution. But it degrades if you only use Thread.yield in your main loop. The fix is to use Thread.sleep(1) instead. But atleast on my computer, Thread.sleep(1) will sometimes sleep for 14 ms instead. Wrecking havoc on the animation.

Use:
F1 to switch between sun.misc.Perf and the new lwjgl timer.
F2 to switch between Thread.yield() and Thread.sleep(1)
“+”, “-” to adjust the amount of triangles that are rendered. I’ve seen difference in behavior depending on the load.

If Perf/yield runs smooth and LWJGL/sleep(1) is choppy, then it is not working properly. You will se the mesured time the sleep took on the “pauseType” line. If it ever gets over 1 when sleep(1) is enabled, then it is also not working.

Only Perf+Yield runs smoothly here on XP
Perf+Sleep is slightly jerky
LWJGL +Yield is medium jerky
LWJGL+Sleep is medium plus jerky.

NB. Time in sleep always >1ms

Perhaps the LWJGL timer is performing some averaging behind the scenes and sleep() is adding a unmeasured random element on top of it.

NB. There was a similar jerky effect on the weapon reload time in my Castle Game demo. My first attempt calculated elapsed time per frame & on each frame subtracted this from a reload time. When this was less then zero, a reload occurred and the reload countdown timer reinitialised. However this “threw away” any time between zero and the final (negative) counter value, resulting in the jerky effect. I fixed this for the player, but left it for the computer controlled entities. It’s almost certainly not the issue here, but worth a mention just in case.

Alan

Spec: Pentium4 2.8GHz, Windows XP, ATI Radeon 9200, JRE 1.4.2 & 1.5

[quote]Only Perf+Yield runs smoothly here on XP
[/quote]
I agree.

WiESi

XP Pro
3.2GHz HT P4
Inspiron 5150
Nvidia GF FX5200 or something

The only one that works for me is LWJGL timer and sleep(1)… all of the others experience periodic slowdowns and speedups.

Is there a pattern to sleep(1) not working right? Is it DOS as opposed to NT? Linux? MacOS? I was expecting sleep(1) to cause problems on 98/ME but I didn’t know how much it would affect everything, not having seen a 98 machine for years…

Cas :slight_smile:

LOL! 98 / ME I meant :slight_smile: Hurrah for teh intarweb.

Cas :slight_smile:

I have experience absolutely no difference between the two at any settings and I added many many spheres 1200+

It just runs smoothly

Windows XP pro SP2
gforce 6800 GT
Radeon 3500+
Nforce 2 chipset
1.3Gb ram

[quote]XP Pro
3.2GHz HT P4
Inspiron 5150
Nvidia GF FX5200 or something

The only one that works for me is LWJGL timer and sleep(1)… all of the others experience periodic slowdowns and speedups.

Is there a pattern to sleep(1) not working right? Is it DOS as opposed to NT? Linux? MacOS? I was expecting sleep(1) to cause problems on 98/ME but I didn’t know how much it would affect everything, not having seen a 98 machine for years…

Cas :slight_smile:
[/quote]
This test will only work on windows. I’ve not included the the native libs for linux and Mac.

Could everyone who tried it also post their spec. In particular what os and what cpu/chipset their using.

Mine are:
-XP sp 2
-AMD athlon XP 1800+
-Via kt 400 chipset
-Radeon 9500 pro

Very little difference for all 4 options. yield produces a slightly higher framerate than sleep(as it should).

Win XP Pro
AMD 1.0GHz
ASUS GeForce 4 MX440
ASUS MB with VIA KT400(I think. It is VIA, not sure of exact chipset)

I’m not getting completely consistant results. Sometimes sleep(1) works, but most times it don’t. I’m wondering if there might be other programs running that sabotages the sleep. Most of the times I’ve got eclipse and Azureus running in the background.

Anyway. I’ll be using sun.misc.Perf as my first choise from now on. Maybe I’ll try to detect when PerformanceCounter don’t work and switch to timeGetTime then.

Interesting. I had Netbeans running and that being Java based may have affected scheduling. Maybe.

For me it runs smooth with both Timers,
i test it on XP sp1.

  • jens

both work for me.

Win XP sp1, Athlon XP 2100+, VIA chipset, GF4 Ti4200, java 1.5.

Perf is definitely more smooth on my machine (P4HT@3.2Ghz) than the new LWJGL timer is. Apart from that, sleep(1) is no option for me, because at least on Windows, it sleeps 15-(time modulo 15) ms (or 10-(time modulo 10) ms on a single CPU/non HT machine) and not just 1ms.