From: Domas Mituzas Date: Wed, 4 Mar 2009 09:37:31 +0000 (+0000) Subject: a handy development utility! X-Git-Tag: 1.31.0-rc.0~42615 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=9e1de2113804678aab3365b39207a6c7d849489e;p=lhc%2Fweb%2Fwiklou.git a handy development utility! --- diff --git a/includes/ProfilerSimpleTrace.php b/includes/ProfilerSimpleTrace.php new file mode 100644 index 0000000000..fcd79ac5ef --- /dev/null +++ b/includes/ProfilerSimpleTrace.php @@ -0,0 +1,66 @@ +mWorkStack[] = array( '-total', 0, $wgRequestTime,$this->getCpuTime($wgRUstart)); + $elapsedcpu = $this->getCpuTime() - $this->getCpuTime($wgRUstart); + $elapsedreal = microtime(true) - $wgRequestTime; + } + $this->trace .= "Beginning trace: \n"; + } + + function profileIn($functionname) { + global $wgDebugFunctionEntry; + $this->mWorkStack[] = array($functionname, count( $this->mWorkStack ), microtime(true), $this->getCpuTime()); + $this->trace .= str_repeat( " ", count($this->mWorkStack) + 14) . " > " . $functionname . "\n"; + } + + function profileOut($functionname) { + global $wgDebugFunctionEntry; + + if ($wgDebugFunctionEntry) { + $this->debug(str_repeat(' ', count($this->mWorkStack) - 1).'Exiting '.$functionname."\n"); + } + + list($ofname, /* $ocount */ ,$ortime,$octime) = array_pop($this->mWorkStack); + + if (!$ofname) { + $this->trace .= "Profiling error: $functionname\n"; + } else { + if ($functionname == 'close') { + $message = "Profile section ended by close(): {$ofname}"; + $functionname = $ofname; + $this->trace .= $message . "\n"; + } + elseif ($ofname != $functionname) { + $self->trace .= "Profiling error: in({$ofname}), out($functionname)"; + } + $elapsedcpu = $this->getCpuTime() - $octime; + $elapsedreal = microtime(true) - $ortime; + $this->trace .= sprintf("%03.6f ",$elapsedreal) . str_repeat(" ",count($this->mWorkStack)+1) . " < " . $functionname . "\n"; + } + } + + function getOutput() { + print ""; + } +}