custom property searching speed question
Alex Tweedly
alex at tweedly.net
Wed Mar 2 17:57:39 EST 2005
Lynch, Jonathan wrote:
>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
>
>
>
Just a warning / reminder :
repeat for each element E in myArray
will process each and every element of the array - but it will do it in
internal (hash value) order. So when you say "only the very last
element contains ...", you need to be aware that they are not being
looked at in the order you might think - i.e. the one containing that
word may be looked at much earlier because of the hashing of the key values.
So in your original problem statement, you said (something like) "and
find the first one that contains" - "first" has a fairly loose meaning
in the context of an array .... if order is crucial to you, you may need
to take the keys of the array, sort that, and then access the elements
by lookup - this will be much, much slower.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.3 - Release Date: 01/03/2005
More information about the use-livecode
mailing list