Created
June 16, 2016 13:53
-
-
Save morontt/c221780adad3434bbe47600c242392e9 to your computer and use it in GitHub Desktop.
benchmark hash and checksum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$test = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the | |
industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and | |
scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into | |
electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of | |
Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus | |
PageMaker including versions of Lorem Ipsum."; | |
echo 'MD5: ' . md5($test) . PHP_EOL; | |
$s0 = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
md5($test); | |
} | |
$s1 = microtime(true); | |
echo ($s1 - $s0) . PHP_EOL . PHP_EOL; | |
echo 'SHA1: ' . sha1($test) . PHP_EOL; | |
$s0 = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
sha1($test); | |
} | |
$s1 = microtime(true); | |
echo ($s1 - $s0) . PHP_EOL . PHP_EOL; | |
echo 'CRC32: ' . hash('crc32', $test) . PHP_EOL; | |
$s0 = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
hash('crc32', $test); | |
} | |
$s1 = microtime(true); | |
echo ($s1 - $s0) . PHP_EOL . PHP_EOL; | |
echo 'ADLER32: ' . hash('adler32', $test) . PHP_EOL; | |
$s0 = microtime(true); | |
for ($i = 0; $i < 100000; $i++) { | |
hash('adler32', $test); | |
} | |
$s1 = microtime(true); | |
echo ($s1 - $s0) . PHP_EOL . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment