Created
July 18, 2015 23:22
-
-
Save tecbeast42/59f9ae2bdab7aa949fed to your computer and use it in GitHub Desktop.
Test your php hash performance
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
//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