Speed testing: Fastest search method

dfepstein at comcast.net dfepstein at comcast.net
Sun Aug 31 10:21:24 EDT 2014


<admin at FlexibleLearning.com> compared 3 methods of stripping lines from a variable, and concluded: 
If memory is an issue, then Method 2 is best 
If memory is not an issue, then Method 3 is best 

3 questions: 

1. Is there a good way to determine ahead of time whether memory is an issue? When I start the handler I can find out how big tVar is, but how do I find out how much memory is available? 

2. Does this step in all 3 handlers -- 
put fld "Data" into tVar 
-- itself use up memory? If fld "Data" is occupying a gigabyte of RAM, does writing it to tVar use another gigabyte? 

3. Method #2 appears to me to violate the rule against modifying the variable to which you are applying "repeat for each": 
#2: 
on mouseUp 
set the cursor to watch 
put the long seconds into tStart 
put fld "data" into tVar 
repeat for each line L in tVar 
add 1 to x 
if L="" then 
put "" into line x of tVar -- RIGHT HERE, WE'RE MODIFYING tVar! 
end if 
end repeat 
put tVar into fld "output" 
put the long seconds - tStart into fld "timer2" 
end mouseUp 

Have I misunderstood that rule? 

Many thanks. 

David Epstein 



More information about the use-livecode mailing list