<?php
class Timer extends Model {

	public $conn = null;
	
	var $starttime = 0;
	var $stoptime = 0;
	var $time = 0;
	
	function __construct() {
		parent::Model();
	}
	
	function getmicrotime() {
		list($usec, $sec) = explode(' ',microtime());
		return ((float)$usec + (float)$sec);
	} 
	function start() {
		$this->starttime = $this->getmicrotime();
		return $this->starttime;
	}
	function meantime() {
		if($tmptime>0) return $this->getmicrotime() - $this->starttime; else return false;
	}
	function stop() {
		$this->stoptime = $this->getmicrotime();
		$this->time = $this->stoptime - $this->starttime;
		
		return number_format($this->time,8);  
	}
	function log($file) {
		$fp = @fopen($file, 'a+');
		@fwrite($fp, date('Y-m-d').';'.$this->time."\n");
		@fclose($fp);
		@chmod($file,0777);
	}
}
?>
