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