<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                **php Timer 頁面運行時間監測類,可按不同key監測不同的運行時間** **Timer.class.php** ~~~ <?php /**Timer class, 計算頁面運行時間,可按不同key計算不同的運行時間 *Date: 2014-02-28 *Author: fdipzone *Ver: 1.0 * *Func: *public start 記錄開始時間 *public end 記錄結束時間 *public getTime 計算運行時間 *pulbic printTime 輸出運行時間 *private getKey 獲取key *private getMicrotime 獲取microtime */ class Timer{ // class start private $_start = array(); private $_end = array(); private $_default_key = 'Timer'; private $_prefix = 'Timer_'; /**記錄開始時間 * @param String $key 標記 */ public function start($key=''){ $flag = $this->getKey($key); $this->_start[$flag] = $this->getMicrotime(); } /**記錄結束時間 * @param String $key 標記 */ public function end($key=''){ $flag = $this->getKey($key); $this->_end[$flag] = $this->getMicrotime(); } /**計算運行時間 * @param String $key 標記 * @return float */ public function getTime($key=''){ $flag = $this->getKey($key); if(isset($this->_end[$flag]) && isset($this->_start[$flag])){ return (float)($this->_end[$flag] - $this->_start[$flag]); }else{ return 0; } } /**輸出頁面運行時間 * @param String $key 標記 * @return String */ public function printTime($key=''){ printf("%srun time %f ms\r\n", $key==''? $key : $key.' ', $this->getTime($key)*1000); } /**獲取key * @param String $key 標記 * @return String */ private function getKey($key=''){ if($key==''){ return $this->_default_key; }else{ return $this->_prefix.$key; } } /**獲取microtime */ private function getMicrotime(){ list($usec, $sec) = explode(' ', microtime()); return (float)$usec + (float)$sec; } } // class end ?> ~~~ **demo:** ~~~ <?php require 'Timer.class.php'; $timer = new Timer(); $timer->start(); $timer->start('program1'); usleep(mt_rand(100000,500000)); $timer->end('program1'); $timer->printTime('program1'); $timer->start('program2'); usleep(mt_rand(100000,500000)); $timer->end('program2'); $timer->printTime('program2'); $timer->end(); $timer->printTime(); ?> ~~~ **demo運行輸出:** ~~~ program1 run time 163.285971 ms program2 run time 100.347042 ms run time 264.035940 ms ~~~ **源碼下載地址:[點擊查看](http://download.csdn.net/detail/fdipzone/6976601)**
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看