MediaWiki REL1_40
langmemusage.php
Go to the documentation of this file.
1<?php
26
27require_once __DIR__ . '/../Maintenance.php';
28
35
36 public function __construct() {
37 parent::__construct();
38 $this->addDescription( "Dumb program that tries to get the memory usage\n" .
39 "for each language file" );
40 }
41
42 public function execute() {
43 if ( !function_exists( 'memory_get_usage' ) ) {
44 $this->fatalError( "You must compile PHP with --enable-memory-limit" );
45 }
46
47 $memlast = $memstart = memory_get_usage();
48
49 $this->output( "Base memory usage: $memstart\n" );
50
51 $languages = array_keys(
52 MediaWikiServices::getInstance()
53 ->getLanguageNameUtils()
54 ->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::SUPPORTED )
55 );
56 sort( $languages );
57
58 foreach ( $languages as $langcode ) {
59 MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( $langcode );
60 $memstep = memory_get_usage();
61 $this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) );
62 $memlast = $memstep;
63 }
64
65 $memend = memory_get_usage();
66
67 $this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" );
68 }
69}
70
71$maintClass = LangMemUsage::class;
72require_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.
A service that provides utilities to do with language names and codes.
Service locator for MediaWiki core services.
$maintClass