Most Effecient way to repeat a handler/function - Found word(s) list error in the Text body
J. Landman Gay
jacque at hyperactivesw.com
Tue Feb 11 12:28:31 EST 2014
On 2/11/14, 9:48 AM, Bob Sneidar wrote:
> For small tasks though, your users will not even be able to blink
> before 100,000 simple repeats are executed. I ran a 100,000 count
> loop with nothing in the repeat loop to do and it took 1 tick. ONE
> TICK! The repeat loop is NOT what slows things down!
Well, it depends. Try running your repeat loop with even a single line
of code inside and use the form "repeat with x = 1 to 100000". That's
the slowest way to do a repeat loop and I think you'll see a difference,
particularly if the single line of code accesses any part of the current
line. Every time through the loop, the engine has to count from 1 all
over again.
For example, try this and compare with your previous results:
put my100000lineData into tData
repeat with x = 1 to 100000
get word 1 of line x of tData
end repeat
If you get word 10 of each line it will slow down more while the engine
counts not only the line number but also the word number.
Benchmarks would be interesting, if anyone has time to try it.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list