欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

这有一个测试页面执行时间的类

程序员文章站 2022-05-01 18:02:35
...
start();
sleep(1);
$timer->stop();
return $timer->show();
}
class timer
{
    var $time_start;
    var $time_end;
    function __construct()
    {
       $this->time_start = 0;
       $this->time_end = 0;
    }
    function timer()
    { 
       $this->__construct();
    }
    function start()
    { 
       list($usec,$sec) = explode(" ",microtime());
       $this->time_start = (float)$usec + (float)$sec;
    }
    function stop()
    { 
       list($usec,$sec) = explode(" ",microtime());
       $this->time_end = (float)$usec + (float)$sec;
    }
    function show($output = false)
    {
       $total = $this->time_end - $this->time_start;
if($output)
{ 
echo $total," sec";
return true;
} 
return $total." sec";
    }
}
?>


教程地址:

欢迎转载!但请带上文章地址^^