3 回答
![?](http://img1.sycdn.imooc.com/5333a1d100010c2602000200-100-100.jpg)
TA贡献1775条经验 获得超11个赞
您可以使用此microtime功能。从文档中:
microtime —返回当前的Unix时间戳(以微秒为单位)
如果get_as_float将设置为TRUE,则microtime()返回一个浮点数,它表示自Unix纪元以来精确到最接近的微秒的当前时间(以秒为单位)。
用法示例:
$start = microtime(true);
while (...) {
}
$time_elapsed_secs = microtime(true) - $start;
![?](http://img1.sycdn.imooc.com/5333a0350001692e02200220-100-100.jpg)
TA贡献2012条经验 获得超12个赞
您可以microtime(true)通过以下方式使用:
将其放在您的php文件的开头:
//place this before any script you want to calculate time
$time_start = microtime(true);
//您的脚本代码在这里
// do something
把它放在你的php文件的末尾:
// Display Script End time
$time_end = microtime(true);
//dividing with 60 will give the execution time in minutes other wise seconds
$execution_time = ($time_end - $time_start)/60;
//execution time of the script
echo '<b>Total Execution Time:</b> '.$execution_time.' Mins';
它将输出结果minutes。
- 3 回答
- 0 关注
- 691 浏览
添加回答
举报