# Best way to calculate framerate per second

I was wondering how to exactly calculte the framerate of and
SDL/OpenGL application with vsync ( 75Hz ) activated.

• I the first way, with a basic

FPS = 1000 / lastframeduration

I get a variable 71 to 76 fps count.

• In a second way, I increment a counter after each frame, and when
one second a time is ended, I do a FPS = fpscounter and I reset
fpscounter to zero for next second, and I get a very constant 75 to
76 fps count.

The second wy seems to be more accurate, but is this a good way to
count each second the frame’s quantity ?

The second way is preferable. The reason it is more stable is because
it is an average over a whole second.

TommyOn 25/04/07, C. Alvarez wrote:

I was wondering how to exactly calculte the framerate of and
SDL/OpenGL application with vsync ( 75Hz ) activated.

• I the first way, with a basic

FPS = 1000 / lastframeduration

I get a variable 71 to 76 fps count.

• In a second way, I increment a counter after each frame, and when
one second a time is ended, I do a FPS = fpscounter and I reset
fpscounter to zero for next second, and I get a very constant 75 to
76 fps count.

The second wy seems to be more accurate, but is this a good way to
count each second the frame’s quantity ?

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

The 2nd way is the way as i know. You could also try to improve it
by keeping an avarage over a longer time-spanne. Meaning, you keep an
array of fps , ie, for the last minute and show the avarage of that.
If you truly want to know the fps for ONE second, just stick to the
method you mentioned.

I think that using the average over a longer time period than one
second would make it hard to find bottle-necks, since the fps will
take longer to react to such. As you say, one second is the standard,
and indeed the ackronym is Frames Per Second. For longer time periods
it should be called something else.On 26/04/07, Stefan Hendriks wrote:

The 2nd way is the way as i know. You could also try to improve it
by keeping an avarage over a longer time-spanne. Meaning, you keep an
array of fps , ie, for the last minute and show the avarage of that.
If you truly want to know the fps for ONE second, just stick to the
method you mentioned.

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I think that using the average over a longer time period than one
second would make it hard to find bottle-necks, since the fps will
take longer to react to such. As you say, one second is the standard,
and indeed the ackronym is Frames Per Second. For longer time periods
it should be called something else.

I totally agree with that. Just mentioned this due the fact i saw this
in Half-Life II (the Source engine). Different kind of metrics where
possible for ‘fps’. One was called ‘avarage fps’. Which could be