X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FProfilerSimple.php;h=5989061dcdba7ede9d03b443842bf8f6ca5e452c;hb=fa4ca02290220f4f83d92e001bbd8ea79e21a032;hp=eb2985ccaebf938b2156aa94ee30f8dfbd11ccce;hpb=ae8554c45b2b5766d4ad59f9a7b12c58198d2142;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ProfilerSimple.php b/includes/ProfilerSimple.php index eb2985ccae..5989061dcd 100644 --- a/includes/ProfilerSimple.php +++ b/includes/ProfilerSimple.php @@ -1,21 +1,24 @@ mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); @@ -25,8 +28,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; @@ -57,7 +59,7 @@ class ProfilerSimple extends Profiler { 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) { @@ -76,10 +78,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; @@ -87,7 +93,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; @@ -106,7 +111,7 @@ class ProfilerSimple extends Profiler { 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; @@ -120,11 +125,4 @@ class ProfilerSimple extends Profiler { list($a,$b)=explode(" ",$time); return (float)($a+$b); } - - function debug( $s ) { - if (function_exists( 'wfDebug' ) ) { - wfDebug( $s ); - } - } } -?>