Re: Suggestion for Fastcode challenge "Hash"

From: Arash Partow (arashp_at_hotmail.com)
Date: 02/24/05

  • Next message: Pierre le Riche: "Re: MM B&V Benchmark weights"
    Date: 23 Feb 2005 22:28:31 -0800
    
    

    Hi,

    Just out of curiosity have you tried any of the hash functions
    on this page: http://www.partow.net/programming/hashfunctions/index.html

    Regards

    Arash
    __________________________________________________
    Be one who knows what they don't know,
    Instead of being one who knows not what they don't know,
    Thinking they know everything about all things.
    http://www.partow.net

    "Juhani Suhonen" <juhani.suhonen@a1netti.cmo> wrote:
    >Very many databases (at least in-memory ones) utilize a hash function
    >to speed up searching within large array of objects; the challenge is
    >to write function which :
    >
    >a) creates a cardinal (longword) hash from any given ansistring
    >
    >b) has property of not creating same hash from similar ansistrings
    >
    >c) has variation of 2^32 values (is able to produce any cardinal
    > value between 0 and 2^32 depending on input)
    >
    >d) an empty input ansistring should return zero
    >
    >Juhani Suhonen
    >---
    >the fastest I know is (from qstrings (C) Andrew N. Driazgov ):
    >
    >function Q_StrHashKey(const S: string): LongWord;
    >asm
    > TEST EAX,EAX
    > JE @@qt
    > LEA EDX,[EAX-1]
    > MOV ECX,[EAX-4]
    > XOR EAX,EAX
    > TEST ECX,ECX
    > JE @@qt
    > PUSH ESI
    > PUSH EBX
    >@@lp: MOV ESI,EAX
    > SHL EAX,5
    > MOVZX EBX,BYTE PTR [EDX+ECX]
    > ADD EAX,ESI
    > ADD EAX,EBX
    > DEC ECX
    > JNE @@lp
    > POP EBX
    > POP ESI
    >@@qt:
    >end;
    >
    >


  • Next message: Pierre le Riche: "Re: MM B&V Benchmark weights"