I agree that this kind of tests are not reliable.
For example:
and this
I wanted to test the fastest way to multiply by 2 and 4 (* operator or binary shift), but the result changes if you just switch the order of the test...
For example:
Graphics 640,480,32,2 ; Calc on the fly Time1=MilliSecs() For a=0 To 10000000 cont=a cont=cont*2 cont=cont*4 Next Time2=MilliSecs() TimeTaken1=Time2-Time1 ; Now Calc using Binary Shift Time1=MilliSecs() For a=0 To 10000000 cont=a cont=cont Shl 1 cont=cont Shl 2 Next Time2=MilliSecs() TimeTaken2=Time2-Time1 Text 10,10,"REPORT" Text 10,30,"Calc using * operator took "+Str(TimeTaken1)+" millisecs" Text 10,45,"Calc using Binary Shift Left took "+Str(TimeTaken2)+" millisecs" Flip WaitKey() End
and this
Graphics 640,480,32,2 ; Now Calc using Binary Shift Time1=MilliSecs() For a=0 To 10000000 cont=a cont=cont Shl 1 cont=cont Shl 2 Next Time2=MilliSecs() TimeTaken2=Time2-Time1 ; Calc on the fly Time1=MilliSecs() For a=0 To 10000000 cont=a cont=cont*2 cont=cont*4 Next Time2=MilliSecs() TimeTaken1=Time2-Time1 Text 10,10,"REPORT" Text 10,30,"Calc using * operator took "+Str(TimeTaken1)+" millisecs" Text 10,45,"Calc using Binary Shift Left took "+Str(TimeTaken2)+" millisecs" Flip WaitKey() End
I wanted to test the fastest way to multiply by 2 and 4 (* operator or binary shift), but the result changes if you just switch the order of the test...