Speed Bump

Phil Davis davis.phil at comcast.net
Fri Feb 10 02:50:32 EST 2006


Use arrays. It reduced my test time by a factor of 10! Here's what I did:

on mouseUp
   repeat 50000
     put random(255) & "," after set1
     put random(255) & "," after set2
   end repeat
   split set1 with comma
   split set2 with comma
   answer "Ready to compare"
   wait 6 ticks
   put the seconds into tStart
   get compareData(set1,set2)
   combine it with comma
   put "arrays = " & the seconds - tStart & cr after msg
   answer "Done"
end mouseUp

function compareData set1,set2
   put (the number of lines in the keys of set1) into xMax
   repeat with x = 1 to xMax
     put max(set1[x],set2[x]) into tData[x]
   end repeat
   return tData
end compareData


Phil Davis



Scott Rossi wrote:
> Greetings List Folks:
> 
> I'm wondering if there's any possible way to trim down the processing time
> required by the following function which takes two sets of data with the
> same number of items, compares the value of each item, and returns a max set
> of data:
> 
> on mouseUp
>   repeat 50000
>     put random(255) & "," after set1
>     put random(255) & "," after set2
>   end repeat
>   answer "Ready to compare"
>   put the seconds into tStart
>   get compareData(set1,set2)
>   put the seconds - tStart
>   answer "Done"
> end mouseUp
> 
> function compareData set1,set2
>   repeat for each item V in set1
>     put max(V,item 1 of set2) after tData
>     delete item 1 of set2
>   end repeat
>   return tData
> end compareData
> 
> On my 600mHz machine this takes about 8 or 9 seconds.  Increasing the item
> count to 100,000 requires 41 seconds.  Ideally, it would be nice to do
> 100,000 items in a few seconds.  Impossible?  Any thoughts?
> 
> Thanks & Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, Multimedia & Design
> -----
> E: scott at tactilemedia.com
> W: http://www.tactilemedia.com
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 




More information about the use-livecode mailing list