Ive no idea why it's so. It MIGHT be possible that different CPU's (or manufacturers of CPU's could give different results, for the sake of informaiton, I am running an AMD X2 64 5600+ chip
My test was done with the following:
Strangely, though.. I have just run the program again a few times, and NOW it seems to indicate ForNext is quicker :S
oops!
My test was done with the following:
ClearWorld SetBuffer FrontBuffer() Global FN1#=0 Global FN2#=0 Global FN3#=0 Global WW1#=0 Global WW2#=0 Global WW3#=0 Global RU1#=0 Global RU2#=0 Global RU3#=0 x=0 ClsColor 0,0,0 Cls ClsColor 255,255,255 Global timer% Delay 1000 Cls timer%=MilliSecs() For x=0 To 33554432 Next stoptime=MilliSecs() FN1=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() While x<=33554432 x=x+1 Wend stoptime=MilliSecs() WW1=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() Repeat x=x+1 Until x>33554432 stoptime=MilliSecs() RU1=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() For x=0 To 33554432 Next stoptime=MilliSecs() FN2=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() While x<=33554432 x=x+1 Wend stoptime=MilliSecs() WW2=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() Repeat x=x+1 Until x>33554432 stoptime=MilliSecs() RU2=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() For x=0 To 33554432 Next stoptime=MilliSecs() FN3=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() While x<=33554432 x=x+1 Wend stoptime=MilliSecs() WW3=stoptime-timer ClsColor 0,0,0 Cls ClsColor 255,255,255 x=0 Delay 1000 Cls timer%=MilliSecs() Repeat x=x+1 Until x>33554432 stoptime=MilliSecs() RU3=stoptime-timer ClsColor 0,0,0 Color 255,255,255 Cls Print "Mean For/Next : "+Int((FN1#+FN2#+FN3#)/3.0)+"ms" Print "Mean While/Wend: "+Int((WW1#+WW2#+WW3#)/3.0)+"ms" Print "Mean Repeat/Until: "+Int((RU1#+RU2#+RU3#)/3.0)+"ms"
Strangely, though.. I have just run the program again a few times, and NOW it seems to indicate ForNext is quicker :S
oops!