Maybe a bit overdoing but....
Huh. I get around 2000 for each of them. Maybe blitz optimises the multiplacations maybe? the odd thing is divide is faster than multiplication for me....
Const inc=10000000 a=Rand(0,$FFFFFF) m=MilliSecs() For i=1 To inc b=a*2 Next m=MilliSecs()-m Print "Multiply by 2: "+m m=MilliSecs() For i=1 To inc b=a Shl 1 Next m=MilliSecs()-m Print "Shl 1: "+m Print "" m=MilliSecs() For i=1 To inc b=a*4 Next m=MilliSecs()-m Print "Multiply by 4: "+m m=MilliSecs() For i=1 To inc b=a Shl 2 Next m=MilliSecs()-m Print "Shl 2: "+m Print "" m=MilliSecs() For i=1 To inc b=a*8 Next m=MilliSecs()-m Print "Multiply by 8: "+m m=MilliSecs() For i=1 To inc b=a Shl 3 Next m=MilliSecs()-m Print "Shl 3: "+m m=MilliSecs() For i=1 To inc b=a/2 Next m=MilliSecs()-m Print "Divide by 2: "+m m=MilliSecs() For i=1 To inc b=a Shr 1 Next m=MilliSecs()-m Print "Shr 1: "+m Print "" m=MilliSecs() For i=1 To inc b=a/4 Next m=MilliSecs()-m Print "Divide by 4: "+m m=MilliSecs() For i=1 To inc b=a Shr 2 Next m=MilliSecs()-m Print "Shr 2: "+m Print "" m=MilliSecs() For i=1 To inc b=a/8 Next m=MilliSecs()-m Print "Divide by 8: "+m m=MilliSecs() For i=1 To inc b=a Shr 3 Next m=MilliSecs()-m Print "Shr 3: "+m
Huh. I get around 2000 for each of them. Maybe blitz optimises the multiplacations maybe? the odd thing is divide is faster than multiplication for me....