Hi Rick,
On my new and fast development machine the search is pretty fast and 
optimization wouldn't be necessary.
But I am not sure, how it behaves on old and weak computers out there in the 
wild. Perhaps I have to reactivate one of my old ones for testing. Splitting 
into alphabetical parts is in my case not possible, because of the "contains" 
search.
Thanks for your ideas
Tiemo

-----Ursprüngliche Nachricht-----
Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von 
Rick Harrison
Gesendet: Mittwoch, 22. April 2015 15:44
An: How to use LiveCode
Betreff: Re: fastes way to search an array?

Hi Tiemo,

What is the average and worst time that it takes to search your 20,000 record 
array now?
Are there users other than you involved? Is it worth the time it will take you 
to optimize the code for the faster execution?

Now that you’ve hopefully answered these questions for yourself, and decided 
it’s worth the effort, let’s more things forward a little more.

Is your array pre-sorted alphabetically? (Assuming you are aiming for that 
order.) If so, it might make sense to split your big array into smaller 
alphabetically sorted arrays.  Then you can test for which array to search 
based on the first letter of the element you are searching for in the array, 
and search the smaller array.

Do a few timed tests with your array search so you can measure how much of an 
improvement you have achieved.

Good luck!

Rick



> On Apr 22, 2015, at 9:20 AM, Tiemo Hollmann TB <toolb...@kestner.de> wrote:
> 
> Hello,
> 
> I have an array with 20000 records, where I want to extract all 
> records, which either "begins with" or "contains" a search string.
> 
> Up to now I just loop thru the whole array, do the compare and extract 
> the result records. I wonder, if there is a way to speed up this 
> search? E.g., does it makes a difference, if I compare the string in 
> the key or the data of the array while looping thru? I mean, would it 
> make a difference, if I would create an "associative" array, where my 
> search looks up in the keys of the array, either by looping thru the 
> array, or by extracting first the keys of the array into a separate 
> variable, instead in the data of the original array?
> 
> Would it make a difference looping thru a variable, which just 
> contains the keys of the array, instead of looping thru the complete 
> array, because of the smaller "footprint" in the memory?
> 
> Or shouldn't I care about these differences and just let LC makes its job?
> 
> Any experiences welcome,
> 
> Tiemo
> 
> 


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to