custom property searching speed question
Lynch, Jonathan
BNZ2 at CDC.GOV
Wed Mar 2 18:02:44 EST 2005
When I created the custom property set, I set the numberformat to
"######". Thus, element 1 is actually named "000001". The unsorted list
of the keys is not quite in alphanumeric order, because almost. When I
put the unsorted list of the keys in the message box, key "500000" is
indeed the last key.
I also tested this with putting the unusual item in element "300000",
and it took like .75 seconds to return the result.
-----Original Message-----
From: use-revolution-bounces at lists.runrev.com
[mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of Alex
Tweedly
Sent: Wednesday, March 02, 2005 5:58 PM
To: How to use Revolution
Subject: Re: custom property searching speed question
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
_______________________________________________
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