Good FPS function

Blitz3D Forums/Blitz3D Programming/Good FPS function

JoshK(Posted 2005) [#1]
This function will update the FPS every time period specified by the frequency parameter, which is set to 200 msecs by default. It takes an average of the elapsed time period, not just a measurement of the last frame. This also makes it easier to read the value when printed on the screen.

Global FPSLASTUPDATETIME
Global FPSFRAMECOUNT
Global FPSLASTCOUNT#

Function FPS#(frequency=200)
time=MilliSecs()
FPSFRAMECOUNT=FPSFRAMECOUNT+1
elapsed#=time-FPSLASTUPDATETIME
If elapsed>=frequency
FPSLASTCOUNT=FPSFRAMECOUNT/elapsed*1000.0
FPSFRAMECOUNT=0
FPSLASTUPDATETIME=time
EndIf
Return FPSLASTCOUNT
End Function


Picklesworth(Posted 2005) [#2]
Thanks for the function.