/halt/Snapshot - Ethna_Plugin_Filter_Benchを参考にしてください。
PEAR::Benchmarkが必要です。
/**
* 実行時間計測フィルタの実装
*
* @author halt feits
* @access public
* @package Ethna
*/
class Ethna_Plugin_Filter_Bench extends Ethna_Plugin_Filter
{
var $bm;
var $use_bm = true;
/**
* 実行前フィルタ
*
* @access public
*/
function preFilter()
{
if ($this->use_bm) {
require_once 'Benchmark/Timer.php';
$this->bm =& new Benchmark_Timer();
$this->bm->start();
}
}
function preActionFilter()
{
if ($this->use_bm) {
$this->bm->setMarker('preAction');
}
}
function postActionFilter()
{
if ($this->use_bm) {
$this->bm->setMarker('postAction');
}
}
/**
* 実行後フィルタ
*
* @access public
*/
function postFilter()
{
if ($this->use_bm) {
$this->bm->stop();
$this->logger->log(LOG_NOTICE, "[{$_SERVER['REQUEST_URI']}] {$this->bm->getOutput(false, 'plain')}");
}
}
}