Re: [請益] PHP 執行時間的 class 或 function
※ 引述《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
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
151
156