Source for file RunTime.php

Documentation is available at RunTime.php

  1. <?PHP
  2. /**
  3. * FIT RunTime
  4. *
  5. * $Id$
  6. *
  7. * @author Luis A. Floreani <luis.floreani@gmail.com>
  8. * @author gERD Schaufelberger <gerd@php-tools.net>
  9. * @package FIT
  10. * @subpackage FileRunner
  11. * @license LGPL http://www.gnu.org/copyleft/lesser.html
  12. * @copyright Copyright (c) 2002-2005 Cunningham & Cunningham, Inc.
  13. */
  14.  
  15. /**
  16. * FIT RunTIme
  17. *
  18. * A simple timer class for minor benchmarks
  19. *
  20. * @version 0.1.0
  21. * @package FIT
  22. * @subpackage Fixture
  23. */
  24. class PHPFIT_RunTime
  25. {
  26. /**
  27. * start time
  28. * @var float
  29. */
  30. private $start;
  31. /**
  32. * construtor
  33. *
  34. * start timer
  35. */
  36. function __construct()
  37. {
  38. $this->start = microtime( true );
  39. }
  40.  
  41. /**
  42. * receive elapsed time as seconds
  43. * @return float $elap
  44. */
  45. public function toString()
  46. {
  47. return microtime( true ) - $this->start . ' seconds';
  48. }
  49. /**
  50. * interface to ask for current timer state
  51. *
  52. * Supports the following properties
  53. * - start when has the timer been started
  54. * - elapsed duration until now
  55. *
  56. * @param string $name of property
  57. * @return mixed
  58. */
  59. public function __get( $name )
  60. {
  61. switch( $name ) {
  62. case 'start':
  63. return $this->start;
  64. break;
  65. case 'elapsed':
  66. return microtime( true ) - $this->start;
  67. break;
  68. default:
  69. break;
  70. }
  71. throw new Exception( 'Property ' . $name . ' is not defined' );
  72. return null;
  73. }
  74. }
  75. ?>

Documentation generated on Sun, 02 Apr 2006 23:21:40 +0000 by phpDocumentor 1.3.0RC5