Home > 类库下载 > PHP类库 > How to write a function to calculate the execution time of a page in PHP

How to write a function to calculate the execution time of a page in PHP

高洛峰
Release: 2016-10-14 11:01:59
Original
1170 people have browsed it

<?php
/*
@ 计算php程序运行时间
*/
function microtime_float()
{
list($usec, $sec) = explode(” “, microtime());
return ((float)$usec + (float)$sec);
}
//开始计时,放在头部
$starttime = microtime_float();
//结束计时,放在最底部
$runtime = number_format((microtime_float() – $starttime), 4).&#39;s&#39;;
//输出
echo ‘RunTime:&#39;.$runtime;
?>
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