Home  >  Article  >  php教程  >  获得页面执行时间

获得页面执行时间

WBOY
WBOYOriginal
2016-06-07 11:43:481175browse

获得页面执行时间
<?php <br /> header("Content-type:text/html;charset=utf-8");<br> class runtime<br> {<br>     private $begintime = 0;<br>     private $endtime   = 0;<br>     private function gettime()<br>     {<br>         list($usec,$sec) = explode(" ", microtime());<br>         return ((float)$usec + (float)$sec);<br>     }<br>     public function begin()<br>     {<br>         $this->begintime = $this->gettime();<br>     }<br>     public function end()<br>     {    <br>         $this->endtime = $this->gettime();<br>     }<br>     public function spent()<br>     {<br>         return round(($this->endtime - $this->begintime) * 1000, 1);<br>     }<br> }<br> $runtime = new runtime();<br> $runtime->begin();<br> for ($i=0; $i      echo $i;<br> }<br> $runtime->end();<br> echo '页面执行时间'.$runtime->spent().'毫秒';<br> ?> 

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
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