1. Performance of Map vs Find()

In Eu 3.1 performance tips it states: Euphoria's find() is the fastest way to search for a value in a sequence up to about 50 elements.

How do maps of 4.x compare with this? Do we have any general guidance on fastest way to do "finds" within sequences of given sizes?

In addition, 4.x documentation states that default threshold for small map is 23. Why 23? Just seems to be a strange number..not 20 or 25 but precisely 23. Did testing prove that 23 is optimal and after that large map is faster?

Looking to optimize a program that does lots of sequence finds on variable size sequences..

Help appreciated as always.

Thanks -casey

new topic     » topic index » view message » categorize

2. Re: Performance of Map vs Find()

cp said...

In Eu 3.1 performance tips it states: Euphoria's find() is the fastest way to search for a value in a sequence up to about 50 elements.

How do maps of 4.x compare with this? Do we have any general guidance on fastest way to do "finds" within sequences of given sizes?

In addition, 4.x documentation states that default threshold for small map is 23. Why 23? Just seems to be a strange number..not 20 or 25 but precisely 23. Did testing prove that 23 is optimal and after that large map is faster?

I think the 4.0 map implementation was done by Derek. I'm not sure about the details, but the 4.1 maps were made even faster. The 4.1 implementation is based on the algorithm used by python dictionaries.

cp said...

Looking to optimize a program that does lots of sequence finds on variable size sequences..

The best thing to do when optimizing is to profile and to test. If using find() is really a bottleneck, try using a map and see if it's better. It is definitely true that as the size of the haystack grows, find() becomes slower (unless you're always looking for stuff up front). The speed of using maps slows down much slower as the haystack grows.

Matt

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu