> Sorry, I missed the earlier posts so I may be missing something, but
> shouldn't you be re-initializing the "i" variable at the top of the
> "a" loop in test2 and test5?
>
D'oh! Good catch, Ken.
Here are the adjusted results. The still show that it's faster to
manually increment the counter than to use a "repeat with" loop. If you
look at the code closely, though, in a triply-nested loop, it makes a
big difference where the "repeat while" is. If it's the outer loop, it's
slower. If it's the inner loops, it's as fast as manually incrementing
the loop counter.
Not as drastic a difference as I got before, but still significant.
test -- 3 "repeat with" loops
-- 10581
-- "100 / 5 / 10001"
test5 -- 3 "repeat while" loops
-- 7287
-- "100 / 5 / 10000"
test2 -- outer "repeat with", inner "repeat while"
-- 7287
-- "100 / 5 / 10001"
test6 --outer repeat while, inner repeat with
-- 10553
-- "100 / 5 / 10000"
test7 -- 2 outer repeat while, one inner repeat with
-- 10583
-- "100 / 5 / 10000"
The scripts:
on test
ms = the milliseconds
repeat with a = 1 to 10000
repeat with i = 0 to 99
repeat with j = 0 to 4
nothing
end repeat
end repeat
end repeat
put the milliseconds - ms
put i & " / " & j & " / " & a
end
on test2
ms = the milliseconds
repeat with a = 1 to 10000
i = 0
repeat while i < 100
j = 0
repeat while j < 5
j = j+1
end repeat
i = i+1
end repeat
end repeat
put the milliseconds - ms
put i & " / " & j & " / " & a
end
on test5
ms = the milliseconds
a = 0
repeat while a < 10000
i = 0
repeat while i < 100
j = 0
repeat while j < 5
j = j+1
end repeat
i = i+1
end repeat
a = a + 1
end repeat
put the milliseconds - ms
put i & " / " & j & " / " & a
end
on test6
ms = the milliseconds
a = 0
repeat while a < 10000
repeat with i = 0 to 99
repeat with j = 0 to 4
nothing
end repeat
end repeat
a = a + 1
end repeat
put the milliseconds - ms
put i & " / " & j & " / " & a
end
on test7
ms = the milliseconds
a = 0
repeat while a < 10000
i = 0
repeat while i < 100
repeat with j = 0 to 4
nothing
end repeat
i = i + 1
end repeat
a = a + 1
end repeat
put the milliseconds - ms
put i & " / " & j & " / " & a
end
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]