MediaWiki  1.23.2
showCacheStats.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Maintenance.php';
25 
31 class ShowCacheStats extends Maintenance {
32 
33  public function __construct() {
34  $this->mDescription = "Show statistics from the cache";
35  parent::__construct();
36  }
37 
38  public function getDbType() {
39  return Maintenance::DB_NONE;
40  }
41 
42  public function execute() {
44 
45  // Can't do stats if
46  if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) {
47  $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true );
48  }
49 
50  $this->output( "\nParser cache\n" );
51  $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_hit' ) ) );
52  $expired = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_expired' ) ) );
53  $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) );
54  $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) );
55  $total = $hits + $expired + $absent + $stub;
56  if ( $total ) {
57  $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
58  $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
59  $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
60  $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
61  $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
62  } else {
63  $this->output( "no statistics available\n" );
64  }
65 
66  $this->output( "\nImage cache\n" );
67  $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) );
68  $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) );
69  $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) );
70  $total = $hits + $misses;
71  if ( $total ) {
72  $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
73  $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
74  $this->output( sprintf( "updates: %-10d\n", $updates ) );
75  } else {
76  $this->output( "no statistics available\n" );
77  }
78 
79  $this->output( "\nDiff cache\n" );
80  $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) );
81  $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) );
82  $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) );
83  $total = $hits + $misses + $uncacheable;
84  if ( $total ) {
85  $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
86  $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
87  $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
88  } else {
89  $this->output( "no statistics available\n" );
90  }
91  }
92 }
93 
94 $maintClass = "ShowCacheStats";
95 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:25
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
ShowCacheStats
Maintenance script that shows statistics from the cache.
Definition: showCacheStats.php:31
$total
$total
Definition: Utf8Test.php:92
wfMemcKey
wfMemcKey()
Get a cache key.
Definition: GlobalFunctions.php:3571
ShowCacheStats\getDbType
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
Definition: showCacheStats.php:38
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ShowCacheStats\__construct
__construct()
Default constructor.
Definition: showCacheStats.php:33
Maintenance\DB_NONE
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:57
ShowCacheStats\execute
execute()
Do the actual work.
Definition: showCacheStats.php:42
$maintClass
$maintClass
Definition: showCacheStats.php:94
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314