lookup3 hash是Bob Jenkins发明的一个非常优秀的hash算法。
Bob Jenkins’s Web Site:
http://www.burtleburtle.net/bob/
性能测试:
From: http://www.azillionmonkeys.com/qed/hash.html
AMD Athlon XP 1.620Ghz
Power4 1Ghz
UltraSparc
III 1.2Ghz
Intel C/C++
CRC32 6.42 5.66 5.66 5.67 14.06 8.75
One at a Time 5.76 5.66 5.66 5.69 12.79 5.57
Alpha Numeric 3.29 4.06 4.06 5.67 10.26 5.52
FNV Hash 4.88 4.84 4.83 4.87 8.92 11.98
Bob Jenkins 2.08 2.36 2.03 2.07 6.16 3.08
SuperFastHash 1.54 1.92 1.59 1.34 3.71 2.15
Data is time in seconds taken to hash a random buffer of 256 bytes 5 million times.
实际应用中lookup3执行效率也相当高,至少是crc32两倍以上的速度,散列效果也很好,现已封装入PHP Extension,方便广大PHPer使用。
项目首页:
http://code.google.com/p/phpfasthash/
下载地址:
http://phpfasthash.googlecode.com/files/lookup3.tar.gz