Code archives/Miscellaneous/FPS counter
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
After poking around through the archives here I didn't happen to see a FPS counting entry yet so figured I'd whip one up. Remember to set anything global if you want to use this in a function or use any of the values in a function (duh) :) | |||||
;Slip this code somewheres immediately before your Flip curTime = MilliSecs() If curTime > checkTime Then checkTime = curTime + 1000 curFPS = fpscounter fpscounter = 0 Else fpscounter = fpscounter + 1 End If |
Comments
| ||
i have packed this up in a nice function:Global fps, fpst,fpsc Graphics3D 1024,768,0,2 SetBuffer BackBuffer() While Not KeyDown(1) ;ESC Cls CountFPS() Text 10,10,"FPS: "+fps Flip Wend End Function CountFPS() If fpst < MilliSecs() Then fpst=MilliSecs()+1000 fps = fpsc fpsc = 0 Else fpsc = fpsc + 1 End If Return fps End Function Just note that it will properly be the same value in case you don't add any gamecode, because all it then needs todo is display the fps text :P |
Code Archives Forum