File size: 1.64Kb
<?php
/**
* Free Wallpaper Script
*
* Free Wallpaper Script by Vepa Halliyev is licensed under a Creative Commons Attribution-Share Alike 3.0 License.
*
* @package Free Wallpaper Script
* @author Vepa Halliyev
* @copyright Copyright (c) 2009, Vepa Halliyev, veppa.com.
* @license http://www.veppa.com/free-wallpaper-script/
* @link http://www.veppa.com/free-wallpaper-script/
* @since Version 1.0
* @filesource
*/
class Benchmark {
static $counter = 0;
static $arr = array();
public static $active = false;
public static $nocache = '';
static function setNoCache($set=true)
{
if($set)
{
self::$nocache = $_SERVER['REQUEST_TIME'];
}
else
{
self::$nocache = '';
}
}
static function cp($title='')
{
self::$counter++;
if(!strlen($title))
{
$title = 'CP ' . self::$counter;
}
if(!count(self::$arr))
{
if(defined('FRAMEWORK_STARTING_MICROTIME'))
{
self::$arr[] = array('t'=>FRAMEWORK_STARTING_MICROTIME,'name'=>'FRAMEWORK_STARTING_MICROTIME');
}
else
{
self::$arr[] = array('t'=>$_SERVER['REQUEST_TIME'],'name'=>'REQUEST_TIME');
}
}
self::$arr[] = array('t'=>microtime(true),'name'=>$title);
}
static function report()
{
self::cp('report');
$t = microtime(true);
foreach(self::$arr as $val)
{
if(!$first)
{
$last_key = $first = $val['t'];
}
$r .= '<tr><td>'.number_format($val['t']-$first,6).'</td><td>'.number_format($val['t']-$last_key,6).'</td><td>'.$val['name'].'</td></tr>';
$last_key = $val['t'];
}
return '<table class="report">'.$r.'</table>';
}
}