Welcome Guest, Not a member yet? Register   Sign In
fastest way to hash a string in an int
#3

[eluser]gungbao[/eluser]
Hola pistolPete,

many thanks for the very interesting links about hashing algorithms.

Code:
abs(crc32($s));

does it perfectly.

Profiling over 10.000 iterations:

abs(crc32($s)) : 0.012081sec
fn integer_hash(): 1.645170 sec
fn md5(): 0.017706sec

Code:
$pattern = '/[a-z]/i';
    $replacement = '';
    $n = preg_replace($pattern, $replacement, md5($s));

runs with 0.077064


Many thanks for your help!
Cheers,
Chris


Messages In This Thread
fastest way to hash a string in an int - by El Forum - 02-23-2009, 04:11 PM
fastest way to hash a string in an int - by El Forum - 02-23-2009, 05:19 PM
fastest way to hash a string in an int - by El Forum - 02-24-2009, 07:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB