PHP Classes
Icontem

File: Timer.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Leandro Lucarella  >  Timer  >  Timer.php  
File: Timer.php
Role: Class source
Content type: text/plain
Description: The Class itself
Class: Timer
Timer class
 

Contents

Class file image Download
<?php

class Timer {

   var 
$classname "Timer";
   var 
$start     0;
   var 
$stop      0;
   var 
$elapsed   0;

   
# Constructor
   
function Timer$start true ) {
      if ( 
$start )
         
$this->start();
   }

   
# Start counting time
   
function start() {
      
$this->start $this->_gettime();
   }

   
# Stop counting time
   
function stop() {
      
$this->stop    $this->_gettime();
      
$this->elapsed $this->_compute();
   }
   
   
# Get Elapsed Time
   
function elapsed() {
      if ( !
$elapsed )
         
$this->stop();

      return 
$this->elapsed;
   }
   
   
# Get Elapsed Time
   
function reset() {
      
$this->start   0;
      
$this->stop    0;
      
$this->elapsed 0;
   }

   
#### PRIVATE METHODS ####
   
   # Get Current Time
   
function _gettime() {
      
$mtime microtime();
      
$mtime explode" "$mtime );
      return 
$mtime[1] + $mtime[0];
   }
   
   
# Compute elapsed time
   
function _compute() {
      return 
$this->stop $this->start;
   }
}

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products