Repeat loop optimization?

Glen Bojsza gbojsza at mac.com
Tue Mar 23 17:57:43 EST 2004


Sarah,

This is incredible...it took 1 second !!

Now I must really play around with "repeat for each" since I am working 
with large data sets.

thank you very much

Glen

On Tuesday, March 23, 2004, at 04:36 PM, Sarah Reichelt wrote:

> Hi Glen,
>
> I reckon you should be able to process all 10000 lines in one go, 
> without to much delay.
> Re-writing your fireBig handler to use "repeat for each" which is MUCH 
> faster than "repeat with":
>
> on firebig
>   put long time into fld sb1
>   put line 1 to 10000 of fld "out" into fbtemp1
>   put empty into sbTime1
>   repeat for each line L in fbTemp1
>     get word 1 to 2 of L
>     convert it to seconds
>     put it & cr after sbtime1
>   end repeat
>   put long time into fld eb1
> end firebig
>
> I would be interested to see how long this takes.
>
> Cheers,
> Sarah
> sarahr at genesearch.com.au
> http://www.troz.net/Rev/
>
> On 24 Mar 2004, at 6:37 am, Glen Bojsza wrote:
>
>> I tried the following experiment.
>>
>> I have a field with 10000 lines and I want to convert the first word 
>> to seconds
>>
>> Method 1
>>
>> Break the 10000 lines into 5 separate loops. The start time and end 
>> time was recorded for each loop - ie when a loop completed the next 
>> loop started.
>>
>> TIME TO PROCESS 21 seconds
>>
>> Method 2 is the same script but with fire# commented out (firebig is 
>> the only loop)
>>
>> TIME TO PROCESS 1 minute 27 seconds
>>
>> 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?
>>
>> on mouseUp
>> fireUpdate
>> end mouseUp
>>
>> on fireUpdate
>>   fire1
>>   fire2
>>   fire3
>>   fire4
>>   fire5
>>   --firebig
>> end fireUpdate
>>
>> on fire1
>>   put long time into fld s1
>>   put line 1 to 2000 of fld "out" into ftemp1
>>   repeat with l = 1 to 2000
>>   get  word 1 of line l of ftemp1 && word 2 of line l of ftemp1
>>     convert it to seconds
>>     put it & cr after stime1
>> end repeat
>> put long time into fld e1
>> end fire1
>>
> snip
>> on firebig
>>   put long time into fld sb1
>>   put line 1 to 10000 of fld "out" into fbtemp1
>>   repeat with l = 1 to 10000
>>   get  word 1 of line l of ftemp1 && word 2 of line l of fbtemp1
>>     convert it to seconds
>>     put it & cr after sbtime1
>> end repeat
>> put long time into fld eb1
>> end firebig
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list