I experimented with the question whether If or Bool is faster in the following example:
Code: Select all
DisableDebugger
Define a=10,b,c,tick1.q,tick2.q,tick3.q
tick1=ElapsedMilliseconds()
For b=1 To 1000000000
c=Bool(a=10)
Next
tick2=ElapsedMilliseconds()
For b=1 To 1000000000
If a=10
c=1
EndIf
Next
tick3=ElapsedMilliseconds()
EnableDebugger
Debug "Bool: "+Str(tick2-tick1)
Debug "If: "+Str(tick3-tick2)
Also, the following code has an even wider gap between the results:
Code: Select all
DisableDebugger
Define a=10,b,c,tick1.q,tick2.q,tick3.q
tick1=ElapsedMilliseconds()
For b=1 To 1000000000
c=5*Bool(a=10)
Next
tick2=ElapsedMilliseconds()
For b=1 To 1000000000
If a=10
c=50
EndIf
Next
tick3=ElapsedMilliseconds()
EnableDebugger
Debug "Bool: "+Str(tick2-tick1)
Debug "If: "+Str(tick3-tick2)