MediaWiki master
langmemusage.php
Go to the documentation of this file.
1<?php
10use MediaWiki\Languages\LanguageNameUtils;
12
13// @codeCoverageIgnoreStart
14require_once __DIR__ . '/../Maintenance.php';
15// @codeCoverageIgnoreEnd
16
23
24 public function __construct() {
25 parent::__construct();
26 $this->addDescription( "Dumb program that tries to get the memory usage\n" .
27 "for each language file" );
28 }
29
30 public function execute() {
31 if ( !function_exists( 'memory_get_usage' ) ) {
32 $this->fatalError( "You must compile PHP with --enable-memory-limit" );
33 }
34
35 $memlast = $memstart = memory_get_usage();
36
37 $this->output( "Base memory usage: $memstart\n" );
38
39 $languages = array_keys(
40 $this->getServiceContainer()
41 ->getLanguageNameUtils()
42 ->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::SUPPORTED )
43 );
44 sort( $languages );
45
46 foreach ( $languages as $langcode ) {
47 $this->getServiceContainer()->getLanguageFactory()->getLanguage( $langcode );
48 $memstep = memory_get_usage();
49 $this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) );
50 $memlast = $memstep;
51 }
52
53 $memend = memory_get_usage();
54
55 $this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" );
56 }
57}
58
59// @codeCoverageIgnoreStart
60$maintClass = LangMemUsage::class;
61require_once RUN_MAINTENANCE_IF_MAIN;
62// @codeCoverageIgnoreEnd
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.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.
$maintClass