Source for file Timer.class.php

Documentation is available at Timer.class.php

  1. <?php
  2.  
  3. /**
  4. * Allows you to time with microtime() from start() to end().
  5. *
  6. * @package harmoni.utilities
  7. *
  8. * @copyright Copyright &copy; 2005, Middlebury College
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  10. *
  11. * @version $Id: Timer.class.php,v 1.5 2007/04/12 15:37:34 adamfranco Exp $
  12. */
  13. class Timer {
  14. var $_start;
  15. var $_end;
  16. function start() {
  17. $this->_start = microtime();
  18. }
  19. function end() {
  20. $this->_end = microtime();
  21. }
  22. function printTime() {
  23. if (!isset($this->_start) || !isset($this->_end)) {
  24. $err = "Must call start() and end() first.";
  25. throwError(new Error($err, "Timer", true));
  26. }
  27. list($sm, $ss) = explode(" ", $this->_start);
  28. list($em, $es) = explode(" ", $this->_end);
  29. $s = $ss + $sm;
  30. $e = $es + $em;
  31. return ($e-$s);
  32. }
  33. }
  34.  
  35. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:26 -0400 by phpDocumentor 1.3.0RC3