Best way to calculate framerate

Note: this goes for all the above implementations in this thread. (except mine of course)

Only if they're so fast that they can warp back in time one second (or a half second in my implementation). There is a conditional test if (elapsed > 1.0) preventing such an occurrance in the example you clipped.

You don't want to update your FPS display every frame; it'll just be unreadable. Once a second is plenty. This gives an average over the second, once a second, approximately. It gives readable results with a minimum of effort.

If you're looking for sharp dips in framerate due to specific events, you'll want something more accurate -- but then you'll want statistics on each and every frame, correllated with certain kinds of events, too...

I do; that's why the smoothing is there. In particular, I want the decimal part (I usually show just one digit) to be a blur, while the integer part smoothly goes up and down, tracking the actual framerate in real-time yet still being perfectly readable.