Skip to content

Instantly share code, notes, and snippets.

@peterchaula
Forked from BlakeGardner/benchmark.php
Last active December 30, 2016 08:45
Show Gist options
  • Save peterchaula/7c57a19497158be9de89895a82b94466 to your computer and use it in GitHub Desktop.
Save peterchaula/7c57a19497158be9de89895a82b94466 to your computer and use it in GitHub Desktop.
Benchmark of all the hashing algorithms provided by PHP
<?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