-
-
Save peterchaula/7c57a19497158be9de89895a82b94466 to your computer and use it in GitHub Desktop.
Benchmark of all the hashing algorithms provided by PHP
This file contains 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 | |
foreach (hash_algos() as $algo) { | |
$start_time = microtime(TRUE); | |
for ($index = 0; $index <= 500000; $index++) { | |
$hash = hash($algo, $index); | |
} | |
$end_time = microtime(TRUE); | |
$total = sprintf('%01.2f', $end_time - $start_time); | |
$times[$algo] = $total; | |
} | |
asort($times); | |
print_r($times); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment