Deleting Data Woefully Slow

Kay C Lan lan.kc.macmail at gmail.com
Wed Mar 24 20:52:13 EDT 2010


Revised Benchmark Script below.

I'd made a mistake copying and pasting, test 6 has been corrected, which
further confirms that delete chunk -1 is woefully slow no matter if you use
'repeat for each' or 'repeat with x ='.

Below are the test results I got on a MBP 2.16GHz, 2 GB RAM, OS X.6.2, Rev
Studio 4.0.0 Build 950

5000 repeats
**repeat for each**
put after = 3 ms
delete line -1 = 299 ms
put before = 11 ms
delete line 1 = 9 ms
**repeat with x = **
put after = 180 ms
delete line -1 = 326 ms
put before = 173 ms
delete line 1 = 10 ms
Create 90% - repeat for each = 2 ms
Create 90% - repeat with x = 372 ms
Delete 10% = 340 ms

50000 repeats
**repeat for each**
put after = 19 ms
delete line -1 = 35429 ms
put before = 1011 ms
delete line 1 = 925 ms
**repeat with x = **
put after = 17746 ms
delete line -1 = 35308 ms
put before = 19343 ms
delete line 1 = 930 ms
Create 90% - repeat for each = 26 ms
Create 90% - repeat with x = 33244 ms
Delete 10% = 31719 ms

The REVISED script I used:

on mouseUp
   repeat 50000 times
      put random (9) & cr after tData
   end repeat
   --test 1
   put the millisec into tStart
   repeat for each line tLine in tData
      put tLine & cr after tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal1
   --test 2
   put the millisec into tStart
   repeat for each line tLine in tData
      delete line -1 of tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal2
   --test 3
   put the millisec into tStart
   repeat for each line tLine in tData
      put tLine & cr before tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal3
   --test 4
   put the millisec into tStart
   repeat for each line tLine in tData
      delete line 1 of tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal4
   --test 5
   put the millisec into tStart
   repeat with tCounter = 1 to the number of lines of tData
      put line tCounter of tData & cr after tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal5

   --test 6 ***REVISED**
   put the millisec into tStart
   repeat with tCounter = 1 to the number of lines of tData
      delete line -1 of tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal6

   --test 7
   put the millisec into tStart
   repeat with tCounter = 1 to the number of lines of tData
      put line tCounter of tData & cr before tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal7
   --test 8
   put the millisec into tStart
   repeat with tCounter = 1 to the number of lines of tData
      delete line 1 of tData1
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal8
   --test 9
   put the millisec into tStart
   repeat for each line tLine in tData
      if NOT(tLIne contains 1) then
         put tLine & cr after tData1
      end if
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal9
   --test 10
   put the millisec into tStart
   repeat with tCounter = 1 to the number of lines of tData
      if NOT(line tCounter of tData contains 1) then
         put line tCounter of tData & cr after tData1
      end if
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal10
   --test 11
   put tData into tData1
   put the millisec into tStart
   repeat with tCounter = the number of lines of tData down to 1
      if NOT(line tCounter of tData contains 1) then
         delete line tCounter of tData1
      end if
   end repeat
   put the millisec into tEnd
   put tEnd - tStart into tTotal11

   put "**repeat for each**" & cr into msg
   put "put after = " & tTotal1 & " ms" & cr after msg
   put "delete line -1 = " & tTotal2 & " ms" & cr after msg
   put "put before = " & tTotal3 & " ms" & cr after msg
   put "delete line 1 = " & tTotal4 & " ms" & cr after msg
   put "**repeat with x = **" & cr after msg
   put "put after = " & tTotal5 & " ms" & cr after msg
   put "delete line -1 = " & tTotal6 & " ms" & cr after msg
   put "put before = " & tTotal7 & " ms" & cr after msg
   put "delete line 1 = " & tTotal8 & " ms" & cr after msg
   put "Create 90% - repeat for each = " & tTotal9 & " ms" & cr after msg
   put "Create 90% - repeat with x = " & tTotal10 & " ms" & cr after msg
   put "Delete 10% = " & tTotal11 & " ms" & cr after msg
end mouseUp



More information about the use-livecode mailing list