Guest

Sam Yong

By: a guest on Aug 23rd, 2009  |  syntax: PHP  |  size: 0.62 KB  |  hits: 128  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. <?php
  2.  
  3. $a = array();
  4. $i = 0;
  5. while($i++ < 1000){
  6. $a[] = dechex(crc32(microtime_float()));
  7. }
  8.  
  9. $i = 0;
  10. $time_start = microtime_float();
  11. while($i++<1000){
  12. $b = $a[count($a)-1];
  13. }
  14. $time_end = microtime_float();
  15. $loadedin = (float)($time_end - $time_start);
  16. echo $loadedin.' s<br/>';
  17.  
  18. $i = 0;
  19. $time_start = microtime_float();
  20. while($i++<1000){
  21. $c = end($a);
  22. }
  23. $time_end = microtime_float();
  24. $loadedin = (float)($time_end - $time_start);
  25. echo $loadedin.' s<br/>';
  26. echo $b.'<br/>'.$c;
  27.  
  28. function microtime_float(){
  29.     list($usec, $sec) = explode(" ", microtime());
  30.     return ((float)$usec + (float)$sec);
  31. }
  32.  
  33. ?>