getHash inconsistency

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 22 11:54:02 PDT 2012


On 3/22/12 1:18 PM, H. S. Teoh wrote:
> Alright, so after some benchmarking, I found that the above custom hash
> function works best for *short* (3 to 10 character) randomized
> alphabetic strings (I assumed alphabetic to be the typical use case of
> strings). It's faster than SuperFastHash, and even has better
> distribution properties, probably because SuperFastHash is tuned for
> arbitrary binary data of arbitrary length, whereas the custom function
> is tuned for short string-like data.
>
> With longer strings, SuperFastHash beats the custom algorithm, and
> distribution properties are approximately the same.
>
> So I'm still on the fence about which algorithm is better. I can see why
> the custom hash was adopted for strings, since your typical AA tends to
> have short alphabetic keys, and something like SuperFastHash is probably
> overkill. But for longer keys, SuperFastHash is better.

Note that you can switch the actual algorithm depending on string length.

Andrei


More information about the Digitalmars-d mailing list