有事没事来多放点。多放点就越来越专业。
三步计算php程序执行时间
上一篇 /
下一篇 2008-04-08 13:26:49
<?phpPHPChina 开源社区门户p7H
q#Kf{'E{L
$stime=microtime(true); //获取程序开始执行的时间PHPChina 开源社区门户9k.Sd)Vy$H
\^
PHPChina 开源社区门户.r+k5B
rmV
echo "hello world"; //你执行的代码
1r.]S*E3n*P
wpMQ+[29605PHPChina 开源社区门户[Uh/t%H%\^%_}A:a
$etime=microtime(true);//获取程序执行结束的时间
.Zi
^)@x\4mr-^#l29605$total=$etime-$stime; //计算差值
'y?UI_a.G:oz29605echo "<br />{$total} times";
r qSB
upPA29605?> PHPChina 开源社区门户(s,E/|6N0h-e5k+a
PHPChina 开源社区门户|bpe6lC9y8TI注意一点:假如执行时间很小,比如0.0000001等,它会使用科学计数法.
+H{l K0rH+F!X+o?29605比如 4.6014785766602E-005 times 并非4.6(注意它后面有个E-005),而是将小数点向前移动5位,真实的值应该是0.000046...
导入论坛
收藏
分享给好友
管理
举报
TAG: