Skip to content

Instantly share code, notes, and snippets.

@rickytato
Forked from BlakeGardner/benchmark.php
Created May 1, 2016 13:54
Show Gist options
  • Save rickytato/96347a6f026fae0508b4350bb32c0db1 to your computer and use it in GitHub Desktop.
Save rickytato/96347a6f026fae0508b4350bb32c0db1 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);
echo "{$total}|{$algo}\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment