Deleting Data Woefully Slow

Mark Wieder mwieder at ahsoftware.net
Thu Mar 25 00:33:32 EDT 2010


Kay-

Wednesday, March 24, 2010, 8:59:18 PM, you wrote:

> Mark and Brian,

> Thanks for your comments.

> Mark you are absolutely right about tests 9, 10 and 11 - it's the problem of
> taking my real life situation and simplifying for the List. I've revised the
> script and this time TESTED the output to confirm the last  3 create
> identical data.

I'm actually more concerned that tests 9, 10, and 11 all rely on the
*content* of lines containing random data. I think you should be using
the line number mod 10 rather than the line content to provide any
meaningful statistics. There's no way you can fill random numbers into
lines of a variable and expect with any certainty that the number "1"
will appear in 10% of the lines.

Also, in tests 9, 10, and 11 you should empty the variable before
adding more data to it in order to provide better comparisons.
Otherwise the variable will be continuing to increase and scaling will
throw off the values.

Test 9 isn't quite a fair comparison (or is, depending on your point
of view): if you want to prove that "repeat for each" is faster than
"repeat with" it's fine (there's about a tenfold speed increase). But
if you're really looking to compare the various "put before" and "put
after"s then you need a bit more code to slow the "repeat for each"
loop down by making it do the same string copy that the others do. One
reason the "for each" form is faster is because it's already got the
line in a buffer without having to go out and retrieve it again.

put 1 into x
repeat for each line tLine in tData
  if NOT(tLIne contains 1) then
    put line x of tData & cr after tData1
  end if
  add 1 to x
end repeat

If you do that you'll see that tests 9 and 10 run at the same speed.

-- 
-Mark Wieder
 mwieder at ahsoftware.net




More information about the use-livecode mailing list