Source for file time_lib.php

Documentation is available at time_lib.php

  1. <?php
  2. // ---------------------------------------------
  3. // Useful time tools
  4. // last modification: 25/02/04 - Alain
  5. // ---------------------------------------------
  6.  
  7. // ---------------------------------------------
  8. // get time in microsecond, and format in second
  9. // ---------------------------------------------
  10.  
  11. function getmicrotime(){
  12. // get micro time and format in second
  13. list($sec, $usec) = explode(" ",microtime());
  14. return ((float)$usec + (float)$sec);
  15. }
  16.  
  17. // ---------------------------------------------
  18. // calculate duration from 2 times
  19. // ---------------------------------------------
  20.  
  21. function exetime($t_start,$t_end) {
  22. // evaluate exe time in second
  23. $e_time = $t_end - $t_start;
  24. $e_time = sprintf("%01.4f",$e_time);
  25. return $e_time;
  26. }
  27.  
  28. // ---------------------------------------------
  29. // combine both previous to deliver a formated result
  30. // ---------------------------------------------
  31.  
  32. function display_exe_time ($time_start, $comment) {
  33. $time_end = getmicrotime();
  34. $duration = exetime($time_start,$time_end);
  35. print "$comment : $duration sec</i><br><br>";
  36. }
  37. ?>

Documentation generated on Mon, 31 Mar 2008 18:09:01 +0200 by phpDocumentor 1.3.0RC3