Home  >  Article  >  Backend Development  >  计算php页面运行时间的函数介绍_php技巧

计算php页面运行时间的函数介绍_php技巧

WBOY
WBOYOriginal
2016-05-17 08:57:21807browse
一个计算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).'s';
//输出
echo ‘RunTime:'.$runtime;
?>
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