MemProfile.php

Go to the documentation of this file.
00001 <?php
00002 if ( !defined( 'MEDIAWIKI' ) ) {
00003     die();
00004 }
00014 
00015 $wgMemUse = array();
00017 $wgMemStack = 0;
00018 
00023 function wfMemIn( $a ) {
00024     global $wgLang, $wgMemUse, $wgMemStack;
00025 
00026     $mem = memory_get_usage();
00027     $memR = memory_get_usage();
00028 
00029     $wgMemUse[$a][] = array( $mem, $memR );
00030 
00031     $memF = $wgLang->formatNum( $mem );
00032     $memRF = $wgLang->formatNum( $memR );
00033 
00034     $pad = str_repeat( ".", $wgMemStack );
00035     wfDebug( "$pad$a-IN: \t$memF\t\t$memRF\n" );
00036     $wgMemStack++;
00037 }
00038 
00043 function wfMemOut( $a ) {
00044     global $wgLang, $wgMemUse, $wgMemStack;
00045 
00046     $mem = memory_get_usage();
00047     $memR = memory_get_usage();
00048 
00049     list( $memO, $memOR ) = array_pop( $wgMemUse[$a] );
00050 
00051     $memF = $wgLang->formatNum( $mem );
00052     $memRF = $wgLang->formatNum( $memR );
00053 
00054     $memD = $mem - $memO;
00055     $memRD = $memR - $memOR;
00056 
00057     $memDF = $wgLang->formatNum( $memD );
00058     $memRDF = $wgLang->formatNum( $memRD );
00059 
00060     $pad = str_repeat( ".", $wgMemStack - 1 );
00061     wfDebug( "$pad$a-OUT:\t$memF ($memDF)\t$memRF ($memRDF)\n" );
00062     $wgMemStack--;
00063 }
Generated on Tue Oct 29 00:00:25 2013 for MediaWiki Translate Extension by  doxygen 1.6.3