2010. 6. 15. 15:05ㆍ언어/PHP
웹개발은 하지 않아서 잘 모르지만 그냥 타이머 찾다가 찾은것.. 괜찮은듯
<?
/**
* This class allows a user to to determine execution
* time of code blocks.
*
* @author John Ciacia <Sidewinder@extreme-hq.com>
* @version 1.0
* @copyright Copyright (c) 2007, John Ciacia
* @license [url=http://opensource.org/licenses/gpl-license.php]Open Source Initiative OSI - The GPL:Licensing | Open Source Initiative[/url] GNU Public License
*/
class Timer {
var $starttime = 0;
var $endtime = 0;
var $elapsed = 0;
var $timername = "Not Named";
public function __construct() {
}
public function start() {
$this->starttime = $this->_time();
}
public function stop() {
$this->endtime = $this->_time();
$this->_compute();
}
public function clear() {
$this->starttime = 0;
$this->endtime = 0;
$this->elapsed = 0;
$this->timername = "Not Named";
}
public function elapsed() {
return $this->elapsed;
}
public function settimername($name) {
$this->timername = $name;
}
public function gettimername() {
return $this->timername;
}
private function _time() {
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
return $mtime;
}
private function _compute() {
$this->elapsed = (($this->endtime) - ($this->starttime));
}
}
?>
'언어 > PHP' 카테고리의 다른 글
chr(10) chr(13) (0) | 2010.07.23 |
---|