计算php脚本执行时间

来源:互联网 发布:天下三萌妹捏脸数据 编辑:程序博客网 时间:2024/05/16 00:43

microtime计算脚本执行时间

[php] view plain copy
 print?
  1. /** 
  2.  * Description:计算当前时间 
  3.  *  
  4.  * @return float 
  5.  */  
  6. function getCurrentTime ()  
  7. {  
  8.     list ($msec$sec) = explode(" ", microtime());  
  9.     return (float)$msec + (float)$sec;  
  10. }  


使用示例

[php] view plain copy
 print?
  1. $begin = getCurrentTime();  
  2. sleep(10);  
  3. $end = getCurrentTime();  
  4. $spend = $end-$begin;  
  5. echo "脚本执行时间为:".$spend."\n";  

0 0
原创粉丝点击