Can this be done faster ?

John Miller johnmiller1950 at sbcglobal.net
Fri Jul 21 14:45:31 EDT 2006


Greetings All,

To clarify how I do this ...

I have a stack that has 2 fields.  The first fields contains 30,000  
lines.  My goal (for the sake of doing something) is to put item 1 of  
each line into item 2 of each line.  When the script is finished, the  
results should be put into field 2.

Using the following script, processing all 30,000 lines takes a  
little over 52 seconds.

on mouseUp
   put empty into cd fld 2
   wait 5 ticks
   put 0 into XX
   put cd fld 1 into listXX
   put the ticks into timer
   repeat for each line L in listXX
     add 1 to XX
     put line XX of listXX into item 2 of line XX of listXX
   end repeat
   put (the ticks - timer)/60
   put listXX into cd fld 2
end mouseUp


Using my script, I can process all 30,000 lines in less than 1 second.
      Using the following values for YY I got the corresponding  
times . . .
		YY = 500 = 1.48 seconds
		YY = 400 = 1.17 seconds
		YY = 300 = .917 seconds
		YY = 200 = .683 seconds
		YY = 100 = .433 seconds
		YY = 50 = .333 seconds

on mouseUp
   put 50 into YY
   put empty into cd fld 2
   wait 5 ticks
   put 0 into XX
   put empty into listYY
   put cd fld 1 into listXX
   put the ticks into timer
   repeat until listXX is empty
     put line 1 to YY of listXX into tempXX
     delete line 1 to YY of listXX
     repeat with x = 1 to YY
       put line x of tempXX into item 2 of line x of tempXX
     end repeat
     put RETURN & tempXX after listYY
   end repeat
   delete line 1 of listYY

   put (the ticks - timer)/60
   put listYY into cd fld 2
end mouseUp


Happy Scripting,
John Miller



More information about the use-livecode mailing list