Asking again ... dont direct me to the code archieve

Blitz3D Forums/Blitz3D Beginners Area/Asking again ... dont direct me to the code archieve

Hansie(Posted 2004) [#1]
@all

Measuring the FrameRate ... whats the best/optimal method ... don't direct me to the code archieves .. there are just as many versions as there are different types of games!


sswift(Posted 2004) [#2]
There is no best method.

Here's the method I use:

At the start of a frame go:

oldtime = newtime
newtime = millisecs()

After updateworld, but before renderworld do one of the following to calculate the framerate:

framerate = 1000.0 / float(newtime-oldtime)

And, for a framerate which doesn't update so fast you can additionalyl go:

FPS = ((FPS * 9) + Framerate) / 10

That averages the fps over several frames.



Sure there might be slightly more accurate alternative methods, but generally one does not need the framerate accurate to thousanths of a second. :-)


Hansie(Posted 2004) [#3]
Forgot to mention that i'm using BlitzPlus only ...


sswift(Posted 2004) [#4]
How does that apply? Is there no millisecs command in Blitzplus? I find that hard to believe. :-)


Ross C(Posted 2004) [#5]
Try this hansie. I use this for all my stuff. Updates every second.

Graphics 800,600
SetBuffer BackBuffer()

Global frame
Global timer
Global fps

While Not KeyHit(1)
	Cls
	
	If MilliSecs()<timer+1000 Then
								frame=frame+1
	Else
								fps=frame
								frame=0
								timer=MilliSecs()
	End If
	
	Text 0,0,"fps="+fps
	Flip 0
Wend



Hansie(Posted 2004) [#6]
@Ross C

Thanks a million! just what I needed! running a fullscreen 800x600x16 I have about 59-60 FPS ...


Ross C(Posted 2004) [#7]
remember that

flip 0


gives you the true FPS

flip


gives you the FPS synced to the monitors refresh rate :)


Hansie(Posted 2004) [#8]
yes, I use FLIP FALSE

but it seems to give me the same FPS no matter resolution I try ... hmmm ...


Ross C(Posted 2004) [#9]
320x240 ? :P


Hansie(Posted 2004) [#10]
same bloody FPS! between 58-60!


Ross C(Posted 2004) [#11]
hmm... are drawing the same aount of stuff to the screen each time? If you are, you won't notice any difference, unless the images are smaller when the res is smaller :)


Ross C(Posted 2004) [#12]
But it really sounds like monitor v-sync is on....


Hansie(Posted 2004) [#13]
		VWait
		Flip False
                text 0,0 "..." + fps
		Wend



Ross C(Posted 2004) [#14]
Or check that the variables used for the code, don't get used or changed else where... Anyway, signing off for the night.

Ta ta!


Hansie(Posted 2004) [#15]
removing the VWAIT command drastically increased the FPS .. dont get it ..


Ross C(Posted 2004) [#16]
Get rid of Vwait! That stops the computer till the monitor refreshes. Good for using in game, but with this on, it's not a true indiction of your games true speed :)


Ross C(Posted 2004) [#17]
SInce your monitor is probably at 60 hz, 60 refreshes per second. You get 60-ish fps :) With it off, the gfx card redraws the screen as quickly as it can, completely ignoring the monitor refresh rate.


Hansie(Posted 2004) [#18]
OK. VWAIT removed ... read somewhere else on this forum that I should use VWAIT every time ...


Ross C(Posted 2004) [#19]
Well, you don't really need it. Just use flip or flip false. Or use flip flase, and create your own timing code, to update the game at what ever FPS you like :)

Anyhow, signing off this time ;)

See ya!


Hansie(Posted 2004) [#20]
Thanks mate