From c0a3a314541bc78f6325aa15ac401b267017c704 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 27 Nov 2004 06:38:41 +0000 Subject: [PATCH] Adjust memory usage stats for overhead as well. Fixed accidental doubling of per-call stats on some calls --- includes/Profiling.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/Profiling.php b/includes/Profiling.php index 7b64e03091..e7e089ac6c 100755 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -63,8 +63,8 @@ class Profiler } function profileOut( $functionname ) { - $time = microtime(); $memory = memory_get_usage(); + $time = microtime(); global $wgDebugProfiling, $wgDebugFunctionEntry; if ( $wgDebugFunctionEntry && function_exists( 'wfDebug' ) ) { @@ -130,13 +130,17 @@ class Profiler $end = explode( ' ', $entry[4]); $end = (float)$end[0] + (float)$end[1]; $elapsed = $end - $start; + $memory = $entry[5] - $entry[3]; + if( $fname == '-overhead-total' ) { $overheadTotal[] = $elapsed; + $overheadMemory[] = $memory; } elseif( $fname == '-overhead-internal' ) { $overheadInternal[] = $elapsed; } } $overheadTotal = array_sum( $overheadTotal ) / count( $overheadInternal ); + $overheadMemory = array_sum( $overheadMemory ) / count( $overheadInternal ); $overheadInternal = array_sum( $overheadInternal ) / count( $overheadInternal ); # Collate @@ -156,6 +160,7 @@ class Profiler # Adjust for profiling overhead $elapsed -= $overheadInternal; $elapsed -= ($subcalls * $overheadTotal); + $memory -= ($subcalls * $overheadMemory); } if ( !array_key_exists( $fname, $this->mCollated ) ) { @@ -164,7 +169,7 @@ class Profiler $this->mMemory[$fname] = 0; $this->mMin[$fname] = 1 << 24; $this->mMax[$fname] = 0; - $this->mOverhead[$fname] = $subcalls; + $this->mOverhead[$fname] = 0; } $this->mCollated[$fname] += $elapsed; -- 2.20.1