作者tkdmaf (皮皮快跑)
看板PHP
标题Re: [请益] PHP 执行时间的 class 或 function
时间Wed Jul 27 17:56:50 2011
※ 引述《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