rendered paste body<?
class Profile {
function Profile($Name) {
$this->m_Name = $Name;
$this->m_Start = $this->GetTimeF();
}
function Event($Name) {
$this->m_Events[] = array('Name' => $Name, 'Time' => $this->GetElapsedTime());
}
function GetTimeF() {
list($usec, $sec) = explode(" ", microtime());
return((float)$usec + (float)$sec);
}
function GetElapsedTime() {
$T = $this->GetTimeF();
return(round($T - $this->m_Start, 4));
}
function RenderAppendFile() {
//$this->Event("End of profiling");
//$fd = fopen($File, "a");
//$Text = "Profile for ".$this->m_Name." [ o = ".GetO()." k = ".GetK()." kt = ".GetKT()." ]\n";
//for($i=0;$i<count($this->m_Events);$i++) {
// $Text.=$this->m_Events[$i]['Time']." ".$this->m_Events[$i]['Name']."\n";
//}
$O = str_replace("'", "", GetO());
$KT = str_replace("'", "", GetKT());
$K = str_replace("'", "", GetK());
if($KT == NULL) $KT="NULL";
if($K == NULL) $K="NULL";
if($O == "") $O = $_SERVER['REQUEST_URI'];
$c = get_defined_constants();
$on = array_search($O, $c, true);
if($on == "") $on = "unknown";
if(ereg("Image", $O)) {
$O = "IMAGE";
$on = "IMAGE";
}
@mssql_query("profile_object @O='$O [$on]', @KT=$KT, @K=$K, @ET=".(float)$this->GetElapsedTime());
//fputs($fd, $Text);
}
function Render($MinimumElapsedTime = 0.00) {
if($this->GetElapsedTime() < $MinimumElapsedTime)
return("");
$HTML = "<!--\r\nProfile for ".$this->m_Name."\r\n";
for($i=0;$i<count($this->m_Events);$i++) {
$HTML.=$this->m_Events[$i]['Time']." ".$this->m_Events[$i]['Name']."\r\n";
}
$HTML.="-->\r\n";
return($HTML);
}
private $m_Name;
private $m_Start;
private $m_Events;
}
?>