MediaWiki REL1_37
langmemusage.php
Go to the documentation of this file.
1<?php
25
26require_once __DIR__ . '/../Maintenance.php';
27
34
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( "Dumb program that tries to get the memory usage\n" .
38 "for each language file" );
39 }
40
41 public function execute() {
42 if ( !function_exists( 'memory_get_usage' ) ) {
43 $this->fatalError( "You must compile PHP with --enable-memory-limit" );
44 }
45
46 $memlast = $memstart = memory_get_usage();
47
48 $this->output( "Base memory usage: $memstart\n" );
49
50 $languages = array_keys(
51 MediaWikiServices::getInstance()
52 ->getLanguageNameUtils()
53 ->getLanguageNames( null, 'mwfile' )
54 );
55 sort( $languages );
56
57 foreach ( $languages as $langcode ) {
58 MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langcode );
59 $memstep = memory_get_usage();
60 $this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) );
61 $memlast = $memstep;
62 }
63
64 $memend = memory_get_usage();
65
66 $this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" );
67 }
68}
69
70$maintClass = LangMemUsage::class;
71require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that tries to get the memory usage for each language file.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
MediaWikiServices is the service locator for the application scope of MediaWiki.
$maintClass