What is the best way to calculate FPS?


I was wondering if there is a better way to calculate the fps. At the moment, I calculate over ten frames and divide this time to give fps like so:

if (tenframes == 0) ticks = TickCount();
tenframes ++;

//draw GL scene

if (tenframes == 10)
tenframes = 0;
ticks = TickCount() - ticks;
fps = float(float(600.0) / float(ticks));

The only problem is that it changes every 10 frames to (sometimes) a completely different value! I was wondering how others calculate fps to see if there is something better…


  • patrick.