Here's what I do:
Declare 2 global variables: FPS, and MS
Find a part of code that gets ran every frame, preferably your main loop.
Place this code:
FPS=(FPS*11+1000/(MILLISEC-MS))/12
MS=MILLISEC
?FPS
You'll notice the *11 and /12 or /(11+1), that will stabilize the number so it moves smoothly, and 11 has been tested as a good smoothness ratio.
Could you refer to the following program?
DIM ITV[60]:FILL ITV,0
PTR=0:PMS=MILLISEC
'START OF LOOP
ITV[PTR]=MILLISEC-PMS
PMS=MILLISEC:PTR=(PTR+1)MOD 60:TTL=0
FOR I=0 TO 59:TTL=TTL+ITV[I]:NEXT I
IF TTL!=0 THEN FPS=60/(TTL/1000) ELSE FPS=0
LOCATE 2,2:?FORMAT$("%6.1F FPS",FPS)
'END OF LOOP
I explain my previous post.
ITV array always stores frame to frame interval of past 60 frames.
MILLISEC system variable is integer, but usually frame to frame interval isn't integer. Therefore I find the solution as average of whole ITV array. And FPS is the reciprocal of it. "/1000" stands for msec to sec modification.