Repeat loop optimization?

Dar Scott dsc at swcp.com
Tue Mar 23 16:03:25 EST 2004


On Tuesday, March 23, 2004, at 01:34 PM, Glen Bojsza wrote:

> This is a substantial difference...can anyone give me some pointers on 
> how I should optimize repeat loops. I thought that doing the one big 
> loop should be as fast as the multiple loops?

'line n' takes time proportional to n.  Looping like this is 
proportional to n^2.  Breaking this up keeps n down.  All that extra 
time is in counting lines.

Use 'repeat for each line' if you can.  This is crucial.  You will 
greatly increase your speed.

Accumulating with 'put ... after ...' is efficient.  Continue with 
that.  I'm assuming that stimeX is global.

On some systems 'convert' will affect the value for the long seconds, 
so you might not be able to time this very well if it gets very fast.

Dar Scott



More information about the use-livecode mailing list