Home > php教程 > php手册 > 这有一个测试页面执行时间的类

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

WBOY
Release: 2016-05-26 08:19:41
Original
1045 people have browsed it

<?php
/**
 * @功能:PHP计时器类
 * @参数:null
 * @返回:string
**/
function timer()
{
$timer = new timer();
$timer->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";
    }
}
?>
Copy after login


教程地址:

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template