You know PRINT and SET CURSOR are such slow commands, using it slows your program down so much and you won't be getting a very accurate fps reading.
Silverman's snippet, replaced PRINT with TEXT:
SET DISPLAY MODE 1024,768,32
SYNC RATE 0
SYNC ON
DIM panell(65535)
CREATE BITMAP 1,1024,768 : SET CURRENT BITMAP 0
rem === MAIN ===
DO
CLS
rem jump out of loop
IF SPACEKEY()=1 THEN EXIT
rem play with the size of the border
u=UPKEY():d=DOWNKEY()
bw = bw+u-d
rem draw panel
ID=1
make_panel(ID,200,200,550,400,RGB(128,128,128),-2,RGB(64,64,64),bw)
panel(ID,200,200)
rem programmer info
INK -2,0
text 0,0,str$(SCREEN FPS())
text 0,20,"Border Width: "+str$(bw)
text 0,40,"UP/DOWN to change border size."
text 0,60,"SPACEBAR to exit."
SYNC:sync
LOOP
`//
CLS
time1=TIMER()
maxi = 10000
FOR ID=2 TO maxi
clone_panel(ID,1)
NEXT ID
FOR ID=1 TO maxi
panel(ID,300,300)
NEXT ID
INK -2,0
time2 = TIMER()-time1
PRINT "It took ";time2;" milliseconds to draw ";maxi;" panels."
PRINT "That's ";time2/(maxi+.0);" milliseconds per panel."
SYNC:WAIT KEY
END
FUNCTION make_panel(ID,ax,ay,bx,by,colour,light,shade,border)
SET CURRENT BITMAP 1
CLS
panell(ID)=ID
`store some common calculations for speed
axinbdr = ax+border
ayinbdr = ay+border
bxinbdr = bx-border
byinbdr = by-border
`borders, light and shade.
INK shade,0
BOX ax,byinbdr,bx,by :`bottom
BOX bxinbdr,ay,bx,byinbdr :`right
INK light,0
BOX ax,ay,bxinbdr,ayinbdr :`top
BOX ax,ayinbdr,axinbdr,byinbdr :`left
`bevelled corners
FOR bev = 0 TO border
BOX bxinbdr,ay+bev,bx-bev,ay+bev
BOX ax,by-bev,ax+bev,by-bev
NEXT bev
`body
INK colour,0
BOX axinbdr,ayinbdr,bxinbdr,byinbdr
IF IMAGE EXIST(ID)=1
IF SCANCODE()<>0
DELETE IMAGE ID
GET IMAGE ID,ax,ay,bx,by
ENDIF
ELSE
GET IMAGE ID,ax,ay,bx,by
ENDIF
SET CURRENT BITMAP 0
ENDFUNCTION
FUNCTION clone_panel(ID_target,ID_source)
panell(ID_target)=panell(ID_source)
ENDFUNCTION
FUNCTION panel(ID,position_X,position_Y)
transparency=0
IF IMAGE EXIST(ID)
PASTE IMAGE panell(ID),position_X,position_Y,transparency
ENDIF
ENDFUNCTION
[edit]
Another method to minimize even the TEXT statement further using bitmap for the graphical interface instead of TEXTing everything.
Obese's original with method:
set display mode 1024,768,32
hide mouse
sync rate 0
sync on
create bitmap 1,200,80
set current bitmap 0
Textbw = -1
rem === MAIN ===
do
rem jump out of loop
if spacekey()=1 then exit
rem play with the size of the border
u=upkey():d=downkey()
bw = bw+u-d
rem draw panel
panel(200,200,550,400,rgb(128,128,128),-2,rgb(64,64,64),bw)
rem programmer info
ink -2,0
gosub TextHandle
text 0,0,str$(SCREEN FPS())
sync:cls
loop
`//
time1=timer()
max = 10000
colour=rgb(128,128,128)
light=-2
shade=rgb(64,64,64)
for i = 1 to max
panel(200,200,550,400,colour,light,shade,20)
next i
ink -2,0
time2 = timer()-time1
print "It took ";time2;" milliseconds to draw ";max;" panels."
print "That's ";time2/(max+.0);" milliseconds per panel."
sync:wait key
end
TextHandle:
if Textbw <> bw
Textbw = bw
set current bitmap 1
cls
text 0,20,"UP/DOWN to change border size."
text 0,40,"SPACEBAR to exit."
text 0,60,"Border Width: "+str$(bw)
set current bitmap 0
endif
copy bitmap 1,0,0,199,79, 0,0,0,199,79
return
rem === FUNCTIONS ===
function panel(ax,ay,bx,by,colour,light,shade,border)
`store some common calculations for speed
axinbdr = ax+border
ayinbdr = ay+border
bxinbdr = bx-border
byinbdr = by-border
`borders, light and shade.
ink shade,0
box ax,byinbdr,bx,by :`bottom
box bxinbdr,ay,bx,byinbdr :`right
ink light,0
box ax,ay,bxinbdr,ayinbdr :`top
box ax,ayinbdr,axinbdr,byinbdr :`left
`bevelled corners
for bev = 0 to border
box bxinbdr,ay+bev,bx-bev,ay+bev
box ax,by-bev,ax+bev,by-bev
next bev
`body
ink colour,0
box axinbdr,ayinbdr,bxinbdr,byinbdr
endfunction
`//
Obease + Latch with method:
set display mode 1024,768,32
hide mouse
sync rate 0
sync on
create bitmap 1,200,80
set current bitmap 0
Textbw = -1
rem === MAIN ===
do
rem jump out of loop
if spacekey()=1 then exit
rem play with the size of the border
u=upkey():d=downkey()
bw = bw+u-d
rem draw panel
panel(200,200,550,400,rgb(128,128,128),-2,rgb(64,64,64),bw)
rem programmer info
ink -2,0
gosub TextHandle
text 0,0,str$(SCREEN FPS())
sync:cls
loop
`//
time1=timer()
max = 10000
colour=rgb(128,128,128)
light=-2
shade=rgb(64,64,64)
for i = 1 to max
panel(200,200,550,400,colour,light,shade,20)
next i
ink -2,0
time2 = timer()-time1
print "It took ";time2;" milliseconds to draw ";max;" panels."
print "That's ";time2/(max+.0);" milliseconds per panel."
sync:wait key
end
TextHandle:
if Textbw <> bw
Textbw = bw
set current bitmap 1
cls
text 0,20,"UP/DOWN to change border size."
text 0,40,"SPACEBAR to exit."
text 0,60,"Border Width: "+str$(bw)
set current bitmap 0
endif
copy bitmap 1,0,0,199,79, 0,0,0,199,79
return
function panel(ax,ay,bx,by,colour,light,shade,border)
if border > 0
rem store some common calculations for speed
axinbdr = ax+border
ayinbdr = ay+border
bxinbdr = bx-border
byinbdr = by-border
rem borders, light and shade.
ink light,0
box ax,ay,bx,by
ink shade,0
box axinbdr,ayinbdr,bx,by
rem bevelled corners
rem top left
startx=bx+1
for y=ay to ayinbdr
dec startx
box startx,y,bx,y
next y
rem bottom right
copy bitmap 0,bxinbdr,ay,bx,ayinbdr,0,ax,byinbdr,axinbdr,by
rem body
ink colour,0
box axinbdr,ayinbdr,bxinbdr,byinbdr
else
ink colour,0
box ax,ay,bx,by
endif
endfunction