Accurate Frame Rates

I’m not sure if it’s because it is late or because I am blind, but I can’t seem to find any info on coding a moderatly accurate framerate counter. Could someone please give me a hand?

Thanks.

I just converted the VolatileDuke demo to Full Screen Exclusive and I’m curious as to how fast it’s running.

every frame, increment a counter.
every second, print the counter, then zero it.

…and for the purposes of counting seconds, System.currentTimeMillis() will do the trick accurately enough. Every frame just see if it’s gone over a second since you last looked.

Cas :slight_smile:

[quote]…and for the purposes of counting seconds, System.currentTimeMillis() will do the trick accurately enough.
[/quote]
just ;D

heheh just is right…

i noted that my loops would run 4 or 5 times without System.getCurrentMillis() returning any different results; then all of a sudden it would change by like 15 or 16 millis…

in the end i just setup it so that it calculates the average framerate over the lifetime of the program.

this is goodenough for my purposes

I’m getting about 450 fps @ 1280x1024x32 with 1 sprite(duke.gif)

does that sound about right? It’s running on a geforce4

After 1 second has passed you will be at most 1.5% inaccurate then. At around 60fps that’s not even measurable so “just” isn’t the word you’re looking for :slight_smile:

Cas :slight_smile:

on a win9x system that error goes upto at most +/-5%.
At 60fps, thats could give an error of +/-3fps, not so inconsiderable :stuck_out_tongue:
anyway! it was meant as a joke, lol ;D