custom property searching speed question

Lynch, Jonathan BNZ2 at CDC.GOV
Wed Mar 2 17:30:11 EST 2005


More tinkering and testing of timing...

I changed the customproperty set so that it contains 500,000 records
with 3 items in each record.

Item 1, the name of the element
Item 2, a bunch of words
Item 3, a number (100)

I created a script that gets the sum of column 3 of this data set - that
is, it adds up item 3 for each element.

This script:

on mouseUp
  put the milliseconds into M
  put the customproperties of field "theData" into myArray
  put 0 into tSum
  set the itemdelimiter to numtochar(30)
  repeat for each element E in myArray
   add item 3 of E to tSum
  end repeat
  put tSum into field "output"
  put ((the milliseconds)-M)/1000 into field "feedback"
end mouseUp

produces the correct result in .486 seconds!

Half a second to sum a column of 500,000 items! 

For comparison purposes - how fast would summing up the third column for
half-a-million records get done in a professional database program?


-----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Lynch,
Jonathan
Sent: Wednesday, March 02, 2005 5:03 PM
To: How to use Revolution
Subject: RE: custom property searching speed question

Does filter work on an array?

Anyway, I experimented with a customproperty set created to contain
500,000 elements - each element contains like 7 words. Only the very
last element contains the word "nonstandard"

So far, the following script is fastest:

on mouseUp
  put the milliseconds into M
  put field "search text" into ST
  put the customproperties of field "theData" into myArray
  repeat for each element E in myArray
    if matchchunk(E,ST) = true then
      put E into field output
      exit repeat
    end if
  end repeat
  put the milliseconds into M2
  put (M2 - M)/1000 into field "feedback"
end mouseUp

Each element was created so that the name of that element is the first
word of the element - meaning I do not have to keep track of which
element we are dealing with - as long as I have the value of the
element, I automatically have the name of the element as well.

If the word being searched for is in the 500,000th element of the custom
property set, then it takes 1.059 seconds to find (with like 4 other
programs running on my computer at the same time)

If the elements are already combined into a single variable, then
lineoffset takes just as long!

I guess repeat for each is exceedingly fast.

If I could figure out how to use filter on an array - and how to get it
to work in the same way as using "contains" then I would test it with
the filter command - but so far this eludes me.

In my experiements with this, it seems that an if-then structure was
faster than a switch structure - is this always true?

_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list