PlayBASIC - Crunching the Numbers - Bye Bye DB - Hello Dbpro
I've mentioned before that I use a collection of standard (mostly useless) bits of code for bench marking ! The code is timing the performance in certain areas (loops/basic math/compares & basic trig mainly). With each update (concerning speed) I stockpile compiled PlayBASIC.exe to track PlayBasic's performance over time.
As a bench mark I've been using DB + Dbpro as guide lines, well performance targets
. While PB has been able and match and generally beat DB classic code executions performance (it kills it's raw 2D graphics performance btw !) when using 'customized' PB code (built in functions). i've tried to keep the tests as generic as possible.
Previously, you had to run an compiled exe to get the better of DBclassic. Since the exe runtime has no safe code. Now interestingly PB is now matching DB classic from the ide, with full safe code integration! Meaning that once you produce an exe, it leaves DBclassic in the dust. Approaching.. DBpro now.
For the comparison, all examples run in 640*480*16 (full screen exclusive) with no limits upon the sync rate. Test Machine Duron 800mhz with GF2 mx 400
Quote: " Dark Basic Pro V1.5
For Next: Addition: (0.25) Milliseconds
For Next: Add/Sub/Mult/Div: (1.27) Milliseconds
For Next: IF/Then True & False: (0.42) Milliseconds
Basic Trig: (12.70) Milliseconds
Total Time In Seconds: (3.269)
"
Quote: " PlayBasic V1.46
For Next: Addition: (1.8) Milliseconds
For Next: Add/Sub/Mult/Div: (10.22) Milliseconds
For Next: IF/Then True & False: (5.67) Milliseconds
Basic Trig: (12.46) Milliseconds
Total Time In Seconds: (7.042)
"
Quote: " Dark Basic V1.08 (registered)
For Next: Addition: (3.55) Milliseconds
For Next: Add/Sub/Mult/Div: (7.60) Milliseconds
For Next: IF/Then True & False: (7.09) Milliseconds
Basic Trig: (19.27) Milliseconds
Total Time In Seconds: (9.111)
"
While it's no surprise DBpro is in front (it's machine code), but given this generic test it's not that much quicker. So if we can improve the basic math performance in VM2 (which we can indeed
) PB will be very comparable to Dbpro in terms of 'calculation' performance.. Which means that our a JIT solution or machine code translators will be able to match and probably exceed Dbpro's raw performance.
This is the test code btw
optexpressions true
Dim TestArrayInt(1000)
Dim TestArrayFloat#(1000)
Dim Results#(100)
TestStart=Timer()
MaxTests=10000
Repeat
Cls 0
frames=frames+1
Test=0
Print "Displaying Average Times for "
Print "Current Frame:"+Str$(frames)
ts=Timer()
For i = 0 To MaxTests
temp=temp+1
Next i
t=Timer()-ts
Results#(test)=results#(test)+t
Print "For Next: Addition:"+Str$(results#(test)/frames)
test=test+1
ts=Timer()
For i = 0 To MaxTests
temp=(temp+1)*lp/(lp+1)-lp
Next i
t=Timer()-ts
Results#(test)=results#(test)+t
Print "For Next: Add + Sub + Mult + Div:"+Str$(results#(test)/frames)
test=test+1
ts=Timer()
For i = 0 To Maxtests
If ThisVariable=0
temp=temp+1
EndIf
If ThisVariable=1
Nothing=0
EndIf
Next i
t=Timer()-ts
Results#(test)=results#(test)+t
Print "For Next: If/Then TRUE and False:"+Str$(results#(test)/frames)
test=test+1
ts=Timer()
Basex#=100
Basey#=100
Radius#=100
For i = 0 To MaxTests
angle=angle+1
X#=BaseX#+(Cos(angle)*Radius#)
Y#=BaseY#+(Sin(angle)*Radius#)
Next i
t=Timer()-ts
Results#(test)=results#(test)+t
Print "Basic Trig Functions:"+Str$(results#(test)/frames)
test=test+1
Sync
Until Frames>200
Print "Test Complete"
testEnd=Timer()-TestSTart
Print "Seconds:"+Str$((Timer()-TestStart)/1000)
Sync
WaitKey