有事没事来多放点。多放点就越来越专业。

三步计算php程序执行时间

上一篇 / 下一篇  2008-04-08 13:26:49

   <?phpPHPChina 开源社区门户p7H q#Kf{'E{L
$stime
=microtime(true); 
//获取程序开始执行的时间PHPChina 开源社区门户9k.Sd)V y$H \^
PHPChina 开源社区门户.r+k5B rmV
echo "hello world";         
//你执行的代码
1r.]S*E3n*P wpMQ+[29605PHPChina 开源社区门户[Uh/t%H%\^%_}A:a
$etime=microtime(true);
//获取程序执行结束的时间
.Z i ^)@x\4mr-^#l29605
$total=$etime-$stime;   
//计算差值
'y?UI_ a.G:oz29605
echo "<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:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

数据统计

  • 访问量: 43991
  • 日志数: 283
  • 图片数: 1
  • 建立时间: 2007-09-07
  • 更新时间: 2008-04-16

RSS订阅

Open Toolbar