note 75741 deleted from function.md5 by danbrown
| From: | danbrown@php.net | Date: | Mon, 18 Jul 2011 13:56:45 +0000 |
| Subject: | note 75741 deleted from function.md5 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181638@lists.php.net to get a copy of this message | ||
Note Submitter: prodigysim
----
I ran a small speed test of my own based on comments by sebastian dot haller at freesurf dot ch and
tszming at gmail dot com.
bin2hex(md5('string', true)) performs faster than md5('string').
However, this binary speed boost does not apply for the hash() function.
<?php
$time=microtime(1);
for ($i=0;$i<100000;$i++)
hash('md5', 'string');
echo microtime(1)-$time,': hash/md5<br>';
$time=microtime(1);
for ($i=0;$i<100000;$i++)
md5('string');
echo microtime(1)-$time,': md5<br>';
$time=microtime(1);
for ($i=0;$i<100000;$i++)
bin2hex(hash('md5', 'string', TRUE));
echo microtime(1)-$time,': bin/hash/md5<br>';
$time=microtime(1);
for ($i=0;$i<100000;$i++)
bin2hex(md5('string', TRUE));
echo microtime(1)-$time,': bin/md5<br>';
?>
Returns:
0.392316102982: hash/md5
0.725342035294: md5
0.421605110168: bin/hash/md5
0.483132839203: bin/md5