Measure FPS

Monkey Forums/Monkey Programming/Measure FPS

Supertino(Posted 2013) [#1]
I have done a search but couldn't find what I was looking for. How are you guys measuring FPS in the apps? Whats the most reliable way?


AdamRedwoods(Posted 2013) [#2]
My son stands next to me with a stopwatch while i try to count the refreshes.

	Method OnRender()
		
		RenderWorld()

		' calculate fps
		renders=renders+1
		If Millisecs()-old_ms>=1000
			old_ms=Millisecs()
			fps=renders
			renders=0
		Endif
		
	End



Supertino(Posted 2013) [#3]
Thanks Adam.


Gerry Quinn(Posted 2013) [#4]
I use something like:

		Local frameTime:Float = gameTime - lastFrame
		frameTime = Max( 0.01, Min( frameTime, 0.3 ) )
		lastFrame = gameTime
		frameRate = frameRate * 0.75 + 0.25 / frameTime


frameRate, gameTime, and lastFrame are persistent floats (i.e. fields or globals).

The last line smooths the values reported, I think it's called an exponential moving average. You can tweak the 0.75 and 0.25, they must add to 1.0.