Timer on steroids?

Started by EgonOlsen, February 02, 2007, 16:46:17

Previous topic - Next topic

EgonOlsen

Over two years have passed and i finally gave the LWJGL-timer another go after having some problems with System.nanotime() caused by dynamic clock speed adjustment of current CPUs. And it STILL runs twice as fast as it should on at least one of my test machines (an older Athlon X2 3800+) using Windows XP. VMs have changed since then, LWJGL versions have...but still the same problem. This is pretty annoying, because it leaves me with three options:


  • Use System.nanotime and make sure that the cpu doesn't throttle. This is possible, but it consumes more cpu power than it actually has to. Not good in times where energy savings are pretty popular.
  • Use System.currentTimeMillis...which is pretty inaccurate.
  • Use LWJGL-Timer and run twice as fast on some machines.

And before somebody asks:

No, nothing is wrong with this machine.
Yes, other games run just fine.
No, it doesn't happen on all LWJGL based apps, just on some of them and
yes, i have all the AMD drivers installed.

This is the code that i'm using for measuring the time:

Timer.tick();
long time=(long) (timer.getTime()*1000f);


Any ideas on what it can be?


kappa

why are you calling Timer.tick() isn't that done automatically in other parts of LWJGL? (could also explain the double speed)

Also i've never used it by creating a Timer object, i just usually call Sys.getTime().

efikkan

I got very similar problems, on some computers my timers always run up to three times as fast, but it works well on most computers.