note 82972 added to function.hash
| From: | inspiration3 at gmail dot com | Date: | Sun, 04 May 2008 15:12:55 +0000 |
| Subject: | note 82972 added to function.hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139051@lists.php.net to get a copy of this message | ||
Another comprehensive benchmark script that orders results from best to worst and includes the
crc32(), md5() and sha1() standalone functions:
<?php
define('HASH_TIMES', 1000);
define('HASH_DATA', 'The quick brown fox jumped over!'); // 32 bytes
header('Content-Type: text/plain');
echo 'Testing ' . strlen(HASH_DATA) . ' bytes of data over ' . HASH_TIMES .
" iterations:\n";
foreach (hash_algos() as $algo) {
$time = microtime(1);
for ($i = 0; $i < HASH_TIMES; $i++) hash($algo, HASH_DATA);
$results[$algo] = microtime(1) - $time;
}
$time = microtime(1); for ($i = 0; $i < HASH_TIMES; $i++) crc32(HASH_DATA);
$results['crc32()'] = microtime(1) - $time;
$time = microtime(1); for ($i = 0; $i < HASH_TIMES; $i++) md5(HASH_DATA);
$results['md5()'] = microtime(1) - $time;
$time = microtime(1); for ($i = 0; $i < HASH_TIMES; $i++) sha1(HASH_DATA);
$results['sha1()'] = microtime(1) - $time;
asort($results, SORT_NUMERIC);
foreach ($results as $algo => $time) echo "\n$time\t$algo";
?>
----
Server IP: 92.48.74.199
Probable Submitter: 87.114.157.40
----
Manual Page -- http://www.php.net/manual/en/function.hash.php
Edit -- https://master.php.net/note/edit/82972
Del: integrated -- https://master.php.net/note/delete/82972/integrated
Del: useless -- https://master.php.net/note/delete/82972/useless
Del: bad code -- https://master.php.net/note/delete/82972/bad+code
Del: spam -- https://master.php.net/note/delete/82972/spam
Del: non-english -- https://master.php.net/note/delete/82972/non-english
Del: in docs -- https://master.php.net/note/delete/82972/in+docs
Del: other reasons-- https://master.php.net/note/delete/82972
Reject -- https://master.php.net/note/reject/82972
Search -- https://master.php.net/manage/user-notes.php