Re: [請益] PHP 執行時間的 class 或 function

看板PHP作者 (皮皮快跑)時間14年前 (2011/07/27 17:56), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
※ 引述《chan15 (ChaN)》之銘言: : 請教一下,有沒有哪邊有不錯的測試程式碼執行時間軟體 : 一個頁面「多段」測試,顯示多段結果的 自己隨手寫一個: <?php class effect_time { var $start_time; var $end_time; function start(){ $this->start_time = $this->_return_time(); return $this->start_time.'<br>'; } function end(){ $this->end_time = $this->_return_time(); return $this->end_time.'<br>'; } function result(){ echo $this->end_time - $this->start_time; } function _return_time(){ list($sec,$min) = explode(' ',microtime()); return $min+$sec; } } ?> 載入之後: $effect_time = new $effect_time; 在要測試的程式起始處: $effect_time->start(); 終止處: $effect_time->end(); 若要看起始或終始時間前面直接加echo。 若要在最後看,就把$effect_time->start_time或是end_time直接印出來。 效能時間:$effect_time->result(); 大致上是這樣。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.118.19
文章代碼(AID): #1EB-3bzC (PHP)
文章代碼(AID): #1EB-3bzC (PHP)