简易程序计算时间

<?php

class Timer{
private $startime;
private $stoptime;
function __contstruct(){
$this->startime=0;
$this->stoptime=0;
}
function start(){
$this->startime=microtime(true);
echo $this->startime.'<br>';
}
function stop(){
$this->stoptime=microtime(true);
echo $this->stoptime.'<br>';
}
function spent(){
return round($this->stoptime-$this->startime,4);
}

}
$timer=new Timer;
$timer->start();
for($i=0;$i<100000 ;$i++ ){

}
$timer->stop();
echo $timer->spent();
?>

你可能感兴趣的:(Web,计算,程序执行时间)