Speed Bump

Jim Ault JimAultWins at yahoo.com
Sun Feb 12 15:16:15 EST 2006


On 2/9/06 11:06 PM, "Scott Rossi" <scott at tactilemedia.com> wrote:
> 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?
> 
There were 3 buttons on a card.
There names were Scott, Phil, Dave.
Clicking each ran a similar script on a Mac G5 dual 2.0 and posted the
results in ticks... the list follows immediately and the scripts afterward.
(Other apps running, including Timbuktu in control mode, Flash, Photoshop,
Excel, Entourage)
Summary = Dave, (25 ticks), Phil(65), Scott(90-150)
Scott's machine:50,000: should take
9 secs * (25/125) = 9/5 = 1.8153422 seconds approx :-)
For 100,000: Dave & Phil 2x longer, Scott 8x longer.
Thus Scott's 600 mHz => 1.8 * 2 = 3.6 seconds

Jim Ault
Las Vegas

who,ticks
dave,26
dave,25
dave,26
dave,24
dave,25
dave,26
phil,64
phil,65
phil,65
phil,64
phil,70
scott,91
scott,89
scott,92
scott,120
scott,149
scott,114
scott,102
scott,105
scott,101
scott,135
dave,25
dave,25
dave,26
dave,29
phil,65
dave,25
scott,141
phil,66
dave,29
scott,105
phil,67
dave,25
dave,27
phil,68
phil,65
scott,152

-------------------------
Scott
on mouseUp
  repeat 50000
    put random(255) & "," after set1
    put random(255) & "," after set2
  end repeat
  --answer "Ready to compare"
  put the ticks into tStart

  get compareData(set1,set2)
  put the ticks - tStart & cr after msg
  --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
  put "scott," after msg
  return tData
end compareData
-------------------------
Phil
on mouseUp
   repeat 50000
     put random(255) & "," after set1
     put random(255) & "," after set2
   end repeat
   --answer "Ready to compare"
   wait 6 ticks
   put the ticks into tStart
   
   split set1 with comma
   split set2 with comma
   get compareData(set1,set2)
   combine it with comma
   put the ticks - 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
  put "phil," after msg
  return tData
end compareData
-------------------------
Dave 
on mouseUp
   repeat 50000
     put random(255) & "," after set1
     put random(255) & "," after set2
   end repeat
   --answer "Ready to compare"
   wait 6 ticks
   put the ticks into tStart

 put the ticks into tStart
  get compareData(set1,set2)
  put the ticks - tStart & cr after msg
   --answer "Done"
end mouseUp

function compareData set1,set2
  split set2 by comma
  put 0 into tCount
  repeat for each item V in set1
    add 1 to tCount
    put max(V,set2[tCount]) after tData
  end repeat
  put "dave," after msg
  return tData
end compareData





More information about the use-livecode mailing list