Skip to content

Instantly share code, notes, and snippets.

@tecbeast42
Created July 18, 2015 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tecbeast42/59f9ae2bdab7aa949fed to your computer and use it in GitHub Desktop.
Save tecbeast42/59f9ae2bdab7aa949fed to your computer and use it in GitHub Desktop.
Test your php hash performance
//Prepare Hashed Data
$toHash = [];
for($i = 0; $i <= 10000;$i++) {
$toHash[] = str_random(1000);
}
$algos = hash_algos();
$results = [];
foreach($algos as $algo) {
$start = microtime(true);
foreach($toHash as $s) {
$temp = hash($algo,$s,false);
}
$results[$algo] = ['seconds' => microtime(true) - $start, 'length' => strlen($temp) ];
}
asort($results);
var_dump($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment