-<?
+<?php
# This file is only included if profiling is enabled
function wfProfileIn( $functionname )
{
function profileOut( $functionname)
{
- global $wgDebugProfiling, $wgDebugFunctionEntry, $wgProfileToDatabase;
+ global $wgDebugProfiling, $wgDebugFunctionEntry;
if ( $wgDebugFunctionEntry && function_exists( "wfDebug" ) ) {
wfDebug( "Exiting $functionname\n" );
if( !count( $this->mStack ) ) {
return "No profiling output\n";
}
+ $this->close();
$width = 125;
$format = "%-" . ($width - 28) . "s %6d %6.3f %6.3f %6.3f%%\n";
$titleFormat = "%-" . ($width - 28) . "s %9s %9s %9s %9s\n";
$end = explode( " ", $entry[3]);
$end = (float)$end[0] + (float)$end[1];
$elapsed = $end - $start;
+
+ if ( !array_key_exists( $fname, $this->mCollated ) ) {
+ $this->mCollated[$fname] = 0;
+ $this->mCalls[$fname] = 0;
+ }
+
$this->mCollated[$fname] += $elapsed;
$this->mCalls[$fname] ++;
}
- $total = $this->mCollated["-total"];
+ $total = @$this->mCollated["-total"];
$overhead = $this->mCollated["-overhead-internal"] / $profileCount;
$this->mCalls["-overhead-total"] = $profileCount;
$prof .= sprintf( $format, $fname, $calls, (float)($elapsed * 1000),
(float)($elapsed * 1000) / $calls, $percent );
+ global $wgProfileToDatabase;
if( $wgProfileToDatabase ) {
Profiler::logToDB( $fname, (float)($elapsed * 1000), $calls );
}
$wgProfiler = new Profiler();
$wgProfiler->profileIn( "-total" );
-
?>