Location: PHPKode > projects > Blackwolf CMF > projectBlackWolf/lib/System/Timer.class.php
<?php
/* Please see the README and LICENSE files. */

/**
 * Assists in knowing microtime since the system started
 */
class System_Timer {
    /**
     * The start time
     * @var int
     */
    protected $start;
    
    /**
     * The stop time
     * @var int
     */
    protected $stop;

    /** 
     * Make a new time, and start it
     */
    public function __construct(){
        $this->start();
    }
    
    /**
     * Update start time
     */
    public function start(){
        $mtime = microtime();
        $mtime = explode(" ",$mtime);
        $mtime = $mtime[1] + $mtime[0];
        $this->start=$mtime;
    }
    
    /**
     * Update the stop time
     * @return int Time since start
     */
    public function stop(){
       $mtime = microtime();
       $mtime = explode(" ",$mtime);
       $mtime = $mtime[1] + $mtime[0];
       $this->stop = $mtime;
       return $this->get_time();
    }  
    
    /**
     * Gets time since last stop
     * @return int
     */
    public function get_time(){
        return ($this->stop)-($this->start);
    }
    
    /**
     * Easy way to print out time with a message for debugging and logging
     * @param String $phrase 
     */
    public function tick($phrase=NULL){
        $this->stop();
        echo("TICK: ".$this->get_time()." $phrase<br/>");
    }
}

?>
Return current item: Blackwolf CMF