Speed testing: Fastest search method
Mike Bonner
bonnmike at gmail.com
Sun Aug 31 10:49:00 EDT 2014
Method 2 doesn't have the filter, I am guessing the lack is a typo? Also,
I'd be interested in your results with the repeat for each method that
modifies tvar with the direct line deletion, though thinking about it,
(since i'm awake now) it wouldn't work unless it was modified. Something
like..
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
delete line x of tVar
subtract 1 from x -- to allow for the deleted line. Also still
wonder about modifying tvar directly in the repeat for each.
end if
end repeat
put tVar into fld "output"
put the long seconds - tStart into fld "timer2"
end mouseUp
On Sun, Aug 31, 2014 at 8:21 AM, <dfepstein at comcast.net> wrote:
> <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
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list