Hello Richard
by testing this code on JB forum
Code:Print "Running 4 timed tests please wait..."
n = 100000
t = time$("ms")
x = 0 : i = 0
while i < n
i = i + 1
x = x + i
wend
t2 = time$("ms")
x = 0 : i = 0
[do]
i = i + 1
x = x + i
if i < n then goto [do]
t3 = time$("ms")
x = 0 : i = 0
10
i = i + 1
x = x + i
if i < n then goto 10
t4 = time$("ms")
x = 0
for i = 0 to n
x = x + i
next
t5 = time$("ms")
print n; " times adding in While... Wend time is ";t2-t
print n; " times adding in GOTO [do] loop time is ";t3-t2
print n; " times adding in GOTO 10 loop time is ";t4-t3
print n; " times adding in FOR loop time is ";t5-t4
I naturally run it in LBB as well, to see how it goes.
And in LBB FOR is significantly faster.
I turned on LBB pane - and I saw FOR translated to
Code:25 FOR i = 0 TO n : WHILE 0 > n EXIT FOR : ENDWHILE
26 x = x + i
27 NEXT
So I just wonder what
Code:WHILE 0 > n EXIT FOR : ENDWHILE
bit is for?
EDIT I wonder if it will run even faster without this check - it looks it is executed on every iteration.