PHP程序来计算PHP脚本的执行时间
要计算PHP脚本的执行时间,代码如下-
示例
<?php
$start = microtime(true);
$val=1;
for($i = 1; $i <=1500; $i++)
{
$val++;
}
$end = microtime(true);
$exec_time = ($end - $start);
echo "The execution time of the PHP script is : ".$exec_time." sec";
?>输出结果
The execution time of the PHP script is : 1.69 sec
“microtime”功能可用于检查PHP脚本完全执行所花费的时间。当代码开始执行时,会记录时间,一旦代码完成,就会生成另一个时间戳,结束时间和开始时间之间的差是脚本完成其执行所花费的时间。
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短