X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FProfilerSimple.php;h=349a7cac1f42929a333b01ef45fe6ff2a463cadf;hb=f9da6c460b6f4cfd457b0ebf1a6e7a347755706b;hp=777a10fd67e7608a07b423fc0d0cf88fe021ed58;hpb=3ea576aa259b9f990e18aa3c58c62036d80c3ce3;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ProfilerSimple.php b/includes/ProfilerSimple.php index 777a10fd67..349a7cac1f 100644 --- a/includes/ProfilerSimple.php +++ b/includes/ProfilerSimple.php @@ -1,18 +1,22 @@ mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); @@ -22,8 +26,7 @@ class ProfilerSimple extends Profiler { $entry =& $this->mCollated["-setup"]; if (!is_array($entry)) { $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); - $this->mCollated[$functionname] =& $entry; - + $this->mCollated["-setup"] =& $entry; } $entry['cpu'] += $elapsedcpu; $entry['cpu_sq'] += $elapsedcpu*$elapsedcpu; @@ -33,24 +36,38 @@ class ProfilerSimple extends Profiler { } } + function setMinimum( $min ) { + $this->mMinimumTime = $min; + } + + function setProfileID( $id ) { + $this->mProfileID = $id; + } + + function getProfileID() { + if ( $this->mProfileID === false ) { + return wfWikiID(); + } else { + return $this->mProfileID; + } + } + function profileIn($functionname) { global $wgDebugFunctionEntry; if ($wgDebugFunctionEntry) { $this->debug(str_repeat(' ', count($this->mWorkStack)).'Entering '.$functionname."\n"); } - $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); + $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); } function profileOut($functionname) { - $memory = memory_get_usage(); - global $wgDebugFunctionEntry; if ($wgDebugFunctionEntry) { $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); } - list($ofname,$ocount,$ortime,$octime) = array_pop($this->mWorkStack); + list($ofname, /* $ocount */ ,$ortime,$octime) = array_pop($this->mWorkStack); if (!$ofname) { $this->debug("Profiling error: $functionname\n"); @@ -59,10 +76,14 @@ class ProfilerSimple extends Profiler { $message = "Profile section ended by close(): {$ofname}"; $functionname = $ofname; $this->debug( "$message\n" ); + $this->mCollated[$message] = array( + 'real' => 0.0, 'count' => 1); } elseif ($ofname != $functionname) { $message = "Profiling error: in({$ofname}), out($functionname)"; $this->debug( "$message\n" ); + $this->mCollated[$message] = array( + 'real' => 0.0, 'count' => 1); } $entry =& $this->mCollated[$functionname]; $elapsedcpu = $this->getCpuTime() - $octime; @@ -70,7 +91,6 @@ class ProfilerSimple extends Profiler { if (!is_array($entry)) { $entry = array('cpu'=> 0.0, 'cpu_sq' => 0.0, 'real' => 0.0, 'real_sq' => 0.0, 'count' => 0); $this->mCollated[$functionname] =& $entry; - } $entry['cpu'] += $elapsedcpu; $entry['cpu_sq'] += $elapsedcpu*$elapsedcpu; @@ -86,10 +106,10 @@ class ProfilerSimple extends Profiler { } function getCpuTime($ru=null) { - if ( function_exists( getrusage() ) { + if ( function_exists( 'getrusage' ) ) { if ( $ru == null ) $ru = getrusage(); - return ($ru['ru_utime.tv_sec'] + $ru['ru_stime.tv_sec'] + ($ru['ru_utime.tv_usec'] + + return ($ru['ru_utime.tv_sec'] + $ru['ru_stime.tv_sec'] + ($ru['ru_utime.tv_usec'] + $ru['ru_stime.tv_usec']) * 1e-6); } else { return 0; @@ -103,11 +123,4 @@ class ProfilerSimple extends Profiler { list($a,$b)=explode(" ",$time); return (float)($a+$b); } - - function debug( $s ) { - if (function_exists( 'wfDebug' ) ) { - wfDebug( $s ); - } - } } -?>