Hi Ashingda 27,
to easily find sources of slowdown may be that this will be useful to you. This is a set of functions that allows you to monitor the execution time of the program in various places.
demo:
autocam off
sync on
sync rate 0
set display mode 800,600,32
rem TOP: indispensable for all SPYTIME() functions
`
`this value can be modified according to user needs
maxbar=10
dim SPYTIMEACTVATE(0) : SPYTIMEACTVATE(0)=1 :`Functions are active by default
dim SPYTIMETIM(maxbar)
dim SPYTIMECOL(maxbar)
dim SPYTIMEKEY$(maxbar) : SPYTIMEKEY$(0)=str$(maxbar)
`
rem BOTTOM: indispensable for all SPYTIME() functions
`init ink color, this is for "check ink color"(in SPYTIMEGRAPH function) works well
ink rgb(255,255,255),0
altkey=56
nextkey=15
rem make scene
max_object=500
for i=1 to max_object
make object sphere i,10
color object i,rgb(0,200,0)
x=rnd(300)-150
y=rnd(100)-50
z=rnd(400)+200
position object i,x,y,z
next i
Fsldwn1=rnd(3000)+2000
Fsldwn2=rnd(30000)+20000
`reset
CLEARSPYTIME()
DO
`turn camera left 4
for i=1 to Fsldwn1 : x#=sqrt(2) : next i
SPYTIME("fake slowdown1")
for i=1 to Fsldwn2 : x#=sqrt(2) : next i
SPYTIME("fake slowdown2")
`if there is too much 'SPYTIME()' call(>maxbar), the excess does not cause error
for i=1 to 50
v$="test"+str$(i)
SPYTIME(v$)
next i
`display results
SPYTIMEGRAPH(altkey,nextkey)
text 0,20,"nb object="+str$(max_object)
text 0,40,"FPS="+str$(screen fps() )
text 0,80,"Alt key = SPYTIMEGRAPH on/off, Tab = next bar"
`reset
CLEARSPYTIME()
SYNC
disp$="display: "+str$(statistic(1))+" polys"
SPYTIME(disp$)
LOOP
end
remstart
`functions:
CLEARSPYTIME()
SPYTIME(key$)
SPYTIMEGRAPH(display_key,next_bar)
remend
function SPYTIMEGRAPH(display_key,next_bar)
rem display_key = keystate code
if SPYTIMEACTVATE(0)=1
`
`check ink color : works well if the INK command has already been called a first time
if first=0
` Background=point(0,0)
dot 0,0
Foreground=point(0,0)
first=1
endif
`bargraph position
x=0
y=20
rem 1 millisecond = 1 pixel * scale_box_height
scale_box_height=1
rem in pixels
box_width=20
curkeystate=keystate(display_key)
if curkeystate>oldkeystate then display=(display!1)
oldkeystate=curkeystate
if display
screenh=screen height()
lony=100*scale_box_height
maxbar=val(SPYTIMEKEY$(0))
ink rgb(255,255,255),0
lonx=maxbar*box_width
line x,screenh-y,x+lonx,screenh-y
line x,screenh-y,x,screenh-y+lony
fin=SPYTIMECOL(0)
for moi=1 to fin
deltat=SPYTIMETIM(moi)
coul=SPYTIMECOL(moi)
ink coul,0
x1=x+1
y1=(screenh-y)-(deltat*scale_box_height)
x2=x+box_width
y2=screenh-y
box x1,y1,x2,y2
ink rgb(255,255,0),0
tabkey=keystate(next_bar)
if tabkey>oldtabkey then inc rolltab
if rolltab>fin-1 then rolltab=0
oldtabkey=tabkey
if rolltab=moi-1
key$=SPYTIMEKEY$(moi)
c$=key$ + " = " + str$(deltat) + " ms"
text 0,screenh-y,c$
box (x2-(box_width/2))x-2,y1-10,(x2-(box_width/2))+2,y1-6
endif
inc x,(box_width)
next moi
ink Foreground,0
endif
`
endif
endfunction
function SPYTIME(key$)
if SPYTIMEACTVATE(0)=1
`
currtime=timer()
maxbar=val(SPYTIMEKEY$(0))
trouv=0
moi=SPYTIMECOL(0)
cumultime=0
for i=1 to maxbar
if SPYTIMEKEY$(i)=key$
trouv=1
moi=i
cumultime=SPYTIMETIM(moi)
i=maxbar
else
if SPYTIMEKEY$(i)="" then i=maxbar
endif
next i
if trouv=0 and moi<maxbar
inc moi
SPYTIMECOL(0)=moi
if SPYTIMECOL(moi)=0
r=rnd(191)+64
g=rnd(191)+64
b=rnd(191)+64
coul=rgb(r,g,b)
SPYTIMECOL(moi)=coul
endif
SPYTIMEKEY$(moi)=key$
endif
oldtime=SPYTIMETIM(0)
SPYTIMETIM(moi)=(currtime-oldtime)+cumultime
SPYTIMETIM(0)=timer()
`
endif
endfunction
function CLEARSPYTIME()
if SPYTIMEACTVATE(0)=1
`
maxbar=val(SPYTIMEKEY$(0))
for i=1 to maxbar
SPYTIMETIM(i)=0
SPYTIMEKEY$(i)=""
next i
SPYTIMECOL(0)=0
SPYTIMETIM(0)=timer()
`
endif
endfunction
DirectX 9.0c (February 2010)/ DBClassic v1.20