| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
use MediaWiki\Languages\LanguageNameUtils; |
| 25 |
|
| 26 |
|
| 27 |
require_once __DIR__ . '/../Maintenance.php'; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class LangMemUsage extends Maintenance { |
| 36 |
|
| 37 |
public function __construct() { |
| 38 |
parent::__construct(); |
| 39 |
$this->addDescription( "Dumb program that tries to get the memory usage\n" . |
| 40 |
"for each language file" ); |
| 41 |
} |
| 42 |
|
| 43 |
public function execute() { |
| 44 |
if ( !function_exists( 'memory_get_usage' ) ) { |
| 45 |
$this->fatalError( "You must compile PHP with --enable-memory-limit" ); |
| 46 |
} |
| 47 |
|
| 48 |
$memlast = $memstart = memory_get_usage(); |
| 49 |
|
| 50 |
$this->output( "Base memory usage: $memstart\n" ); |
| 51 |
|
| 52 |
$languages = array_keys( |
| 53 |
$this->getServiceContainer() |
| 54 |
->getLanguageNameUtils() |
| 55 |
->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::SUPPORTED ) |
| 56 |
); |
| 57 |
sort( $languages ); |
| 58 |
|
| 59 |
foreach ( $languages as $langcode ) { |
| 60 |
$this->getServiceContainer()->getLanguageFactory()->getLanguage( $langcode ); |
| 61 |
$memstep = memory_get_usage(); |
| 62 |
$this->output( sprintf( "%12s: %d\n", $langcode, ( $memstep - $memlast ) ) ); |
| 63 |
$memlast = $memstep; |
| 64 |
} |
| 65 |
|
| 66 |
$memend = memory_get_usage(); |
| 67 |
|
| 68 |
$this->output( ' Total Usage: ' . ( $memend - $memstart ) . "\n" ); |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
$maintClass = LangMemUsage::class; |
| 74 |
require_once RUN_MAINTENANCE_IF_MAIN; |
| 75 |
|