From: Antoine Musso Date: Thu, 28 Aug 2008 16:22:10 +0000 (+0000) Subject: wfDebugMem() to report memory usage X-Git-Tag: 1.31.0-rc.0~45592 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=commitdiff_plain;h=8ec6021ab76710efe0e9ed8627825750d4234d54;p=lhc%2Fweb%2Fwiklou.git wfDebugMem() to report memory usage --- 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.