Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- <?php
- function microtime_float() {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
- }
- $algos = hash_algos();
- $string = "The quick brown fox jumped over the lazy dog.";
- echo "Prints out hash of the string \"".$string."\"\nusing the different algorithms you have installed in your PHP setup.\n";
- echo "It runs the hash function 1000 times and calculates the mean value of the execution time.\n";
- echo "The execution time is presented in milliseconds\n\n";
- foreach($algos as $algo) {
- echo $algo . "\n";
- echo hash($algo, $string) . "\n";
- $res_time = 0;
- for($i = 0; $i < 1000;$i++) {
- $time_start = microtime_float();
- hash($algo, $string);
- $res_time += microtime_float() - $time_start;
- }
- echo "Executed in " . round($res_time*1000, 3) . " milliseconds\n";
- echo "\n\n";
- }
- ?>
- </pre>
Add Comment
Please, Sign In to add comment