daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Jul 19th, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <pre>
  2. <?php
  3.  
  4. function microtime_float() {
  5.     list($usec, $sec) = explode(" ", microtime());
  6.     return ((float)$usec + (float)$sec);
  7. }
  8. $algos = hash_algos();
  9. $string = "The quick brown fox jumped over the lazy dog.";
  10.  
  11.  
  12. echo "Prints out hash of the string \"".$string."\"\nusing the different algorithms you have installed in your PHP setup.\n";
  13. echo "It runs the hash function 1000 times and calculates the mean value of the execution time.\n";
  14. echo "The execution time is presented in milliseconds\n\n";
  15.  
  16. foreach($algos as $algo) {
  17.  
  18.   echo $algo . "\n";
  19.   echo hash($algo, $string) . "\n";
  20.   $res_time = 0;
  21.   for($i = 0; $i < 1000;$i++) {
  22.     $time_start = microtime_float();
  23.     hash($algo, $string);
  24.     $res_time += microtime_float() - $time_start;
  25.   }
  26.  
  27.   echo "Executed in " . round($res_time*1000, 3) . " milliseconds\n";
  28.   echo "\n\n";  
  29. }
  30. ?>
  31. </pre>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top