Code archives/3D Graphics - Misc/Simple FPS Counter

This code has been declared by its author to be Public Domain code.

Download source code

Simple FPS Counter by Rob Farley2002
I know there have been loads of these kicking around, and some very complex ones to stop flutter, however, this is VERY simple and doesn't flutter.

OK all this does is counts n frames then sees how long it took to do those n frames, this means it updates as often or infrequently as you set.

To change the frequency of update simply change the frequency variable.

Just plonk this code after your renderworld, and the set up bit before your main loop.
;set up fps counter
fps_milli=MilliSecs(): fps_counter=0: update_frequency=10



mainloop
..
..
updateworld
renderworld

; fps counter
fps_counter=fps_counter+1
If fps_counter=update_frequency
     fps=1000/Float(((MilliSecs()-fps_milli))/update_frequency)
     fps_milli=MilliSecs()
     fps_counter=0
     endif

; print fps
Text 0,0,"FPS:"+fps

Comments

electronin2004
Very usefull! thanks :)


Code Archives Forum