MediaWiki  REL1_22
langmemusage.php
Go to the documentation of this file.
00001 <?php
00025 require_once __DIR__ . '/../Maintenance.php';
00026 require_once __DIR__ . '/languages.inc';
00027 
00033 class LangMemUsage extends Maintenance {
00034 
00035     public function __construct() {
00036         parent::__construct();
00037         $this->mDescription = "Dumb program that tries to get the memory usage\n" .
00038             "for each language file";
00039     }
00040 
00041     public function execute() {
00042         if ( !function_exists( 'memory_get_usage' ) ) {
00043             $this->error( "You must compile PHP with --enable-memory-limit", true );
00044         }
00045 
00046         $langtool = new languages();
00047         $memlast = $memstart = memory_get_usage();
00048 
00049         $this->output( "Base memory usage: $memstart\n" );
00050 
00051         foreach ( $langtool->getLanguages() as $langcode ) {
00052             Language::factory( $langcode );
00053             $memstep = memory_get_usage();
00054             $this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) );
00055             $memlast = $memstep;
00056         }
00057 
00058         $memend = memory_get_usage();
00059 
00060         $this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" );
00061     }
00062 }
00063 
00064 $maintClass = "LangMemUsage";
00065 require_once RUN_MAINTENANCE_IF_MAIN;