Re: Hashing strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Barnett wrote:

Gerard Samuel wrote:
...


Im trying to determine if md5() would be the fastest,
*cheapest* solution.


...


What Im looking for is something where the generated hashes can
be reproduced.
For example, md5('foo') today, will be equal to md5('foo') tomorrow.
Thanks



AFAIK crc32() is the fastest hashing function in PHP. I don't have actual results on hand still, but I created a filesystem plugin that auto-generates hashes for each file in a directory. crc32() was faster than md5() and sha1().

FYI the benchmarking that I did was for a Windows XP system... YMMV


I normally profile with apd, but it only measures in the hundredth of a second. So I used getrusage() & memory_get_usage() functions to *unscientifically* profile md5()/sha1()/crc32() on FreeBSD 5.3.

I ran a for loop 75 times, hashing the constant __FILE__
These are an average of 5 runs ->
----
md5: Usertime -> 784.2 µsec
Systemtime -> 72.2 µsec
Memory -> 120.0 bytes


sha1:
Usertime -> 846.8 µsec
Systemtime -> 150.2 µsec
Memory -> 80.0 bytes
crc32:
Usertime -> 194.8 µsec
Systemtime -> 54.2 µsec
Memory -> 80.0 bytes


Can you shed some light on that code,
that you're using for the filesystem plugin?

Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux