Bmax

BlitzMax Forums/BlitzMax Programming/Bmax

(woops title should be "Bmax optimisation problems")


It seems to me that bmax, while very fast at drawing, has some optimisation problems:

This:

Function sq(x#)
Return x*x
End Function

t=MilliSecs()
Local a#

For i=0 To 10000000
a=sq(2)
Next

Print (MilliSecs()-t)


runs in 700 millisecs

While this:

t=MilliSecs()
Local a#
For i=0 To 10000000
a=2*2
Next
Print (MilliSecs()-t)


runs in 70 millisecs.

'Cmon, it 10 times more!! This discourages the use of functions a lot!

I dont know what C does, but I would be surprised if it took 10 times more.

The second example


Function f(x#)
Local a#=x+3
Local b#=a*5
Return b

End Function


t=MilliSecs()

Local a#
For i=0 To 10000000
a=f(2)
Next

Print (MilliSecs()-t)



takes 950 millisecs

while



Function f(x#)
Return (x+3)*5

End Function

t=MilliSecs()

Local a#
For i=0 To 10000000
a=f(2)
Next

Print (MilliSecs()-t)



takes 700 millisecs, while they should be the same if it was decently optimized