您好,欢迎访问一九零五行业门户网

解读PHP计算页面执行时间的具体代码实现_PHP教程

通过对php计算页面执行时间的代码如下所示:
php class runtime  {      var $starttime = 0;      var $stoptime = 0;         function get_microtime()      {          list($usec, $sec) = explode(' ', microtime());          return ((float)$usec + (float)$sec);      }         function start()      {          $this->starttime = $this->get_microtime();      }         function stop()      {          $this->stoptime = $this->get_microtime();      }         function spent()      {          return round(($this->stoptime - $this->starttime) * 1000, 1);      }     }        //例子  $runtime= new runtime;  $runtime->start();     //你的代码开始     $a = 0;  for($i=0; $i1000000; $i++)  {      $a += $i;  }     //你的代码结束     $runtime->stop();  echo 页面执行时间: .$runtime->spent(). 毫秒;     ?> 
通过对php计算页面执行时间的代码的了解,新手们应该自己再实际操作一遍,以加深自己的理解。
http://www.bkjia.com/phpjc/446322.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/446322.htmltecharticle通过对 php计算页面执行时间的代码如下所示: ? php classruntime { var$ starttime = 0 ; var$ stoptime = 0 ; functionget_microtime() { list($usec,$sec)=explode('',mi...
其它类似信息

推荐信息