From 8ec6021ab76710efe0e9ed8627825750d4234d54 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 28 Aug 2008 16:22:10 +0000 Subject: [PATCH] wfDebugMem() to report memory usage --- includes/GlobalFunctions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 49de9f1e5f..01ac7ab402 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -231,6 +231,20 @@ function wfDebug( $text, $logonly = false ) { } } +/** + * Send a line giving PHP memory usage. + * @param $exact Bool : print exact values instead of kilobytes (default: false) + */ +function wfDebugMem( $exact = false ) { + $mem = memory_get_usage(); + if( !$exact ) { + $mem = floor( $mem / 1024 ) . ' kilobytes'; + } else { + $mem .= ' bytes'; + } + wfDebug( "Memory usage: $mem\n" ); +} + /** * Send a line to a supplementary debug log file, if configured, or main debug log if not. * $wgDebugLogGroups[$logGroup] should be set to a filename to send to a separate log. -- 2.20.1