note 76078 added to function.md5
| From: | AzuMao at gmail dot com | Date: | Fri, 29 Jun 2007 01:53:29 +0000 |
| Subject: | note 76078 added to function.md5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128069@lists.php.net to get a copy of this message | ||
Here is a far more accurate test if you are not going to be doing it over and over.
<?php
$time=microtime(1);
hash('md5', 'string');
echo (microtime(1)-$time)*10000,': hash/md5<br>';
$time=microtime(1);
md5('string');
echo (microtime(1)-$time)*10000,': md5<br>';
$time=microtime(1);
hash('sha1', 'string');
echo (microtime(1)-$time)*10000,': hash/sha1<br>';
$time=microtime(1);
sha1('string');
echo (microtime(1)-$time)*10000,': sha1<br>';
?>
Outputs
0.11920928955078: hash/md5
0.090599060058594: md5
0.14066696166992: hash/sha1
0.050067901611328: sha1
Refresh it a few times and you will see that it is indeed consistant. sha1 is faster if you are not
going to be using it over and over. I'm using this for etags in PHP and only need to use it
once, so for me sha1 is faster.
Note that these times are all times by 10000 so that it shows up as a real number instead of
something like
1.1920928955078E-5: hash/md5
8.1062316894531E-6: md5
1.4066696166992E-5: hash/sha1
5.9604644775391E-6: sha1
(to negative powers)
----
Server IP: 208.69.120.35
Probable Submitter: 67.53.37.218
----
Manual Page -- http://www.php.net/manual/en/function.md5.php
Edit -- https://master.php.net/note/edit/76078
Del: integrated -- https://master.php.net/note/delete/76078/integrated
Del: useless -- https://master.php.net/note/delete/76078/useless
Del: bad code -- https://master.php.net/note/delete/76078/bad+code
Del: spam -- https://master.php.net/note/delete/76078/spam
Del: non-english -- https://master.php.net/note/delete/76078/non-english
Del: in docs -- https://master.php.net/note/delete/76078/in+docs
Del: other reasons-- https://master.php.net/note/delete/76078
Reject -- https://master.php.net/note/reject/76078
Search -- https://master.php.net/manage/user-notes.php