Home  >  Article  >  类库下载  >  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

高洛峰
高洛峰Original
2016-10-14 11:01:591152browse

<?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;
?>


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

Related articles

See more