MediaWiki
REL1_23
|
00001 <?php 00024 require_once __DIR__ . '/Maintenance.php'; 00025 00031 class ShowCacheStats extends Maintenance { 00032 00033 public function __construct() { 00034 $this->mDescription = "Show statistics from the cache"; 00035 parent::__construct(); 00036 } 00037 00038 public function getDbType() { 00039 return Maintenance::DB_NONE; 00040 } 00041 00042 public function execute() { 00043 global $wgMemc; 00044 00045 // Can't do stats if 00046 if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) { 00047 $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true ); 00048 } 00049 00050 $this->output( "\nParser cache\n" ); 00051 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_hit' ) ) ); 00052 $expired = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_expired' ) ) ); 00053 $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) ); 00054 $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) ); 00055 $total = $hits + $expired + $absent + $stub; 00056 if ( $total ) { 00057 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); 00058 $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) ); 00059 $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) ); 00060 $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) ); 00061 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) ); 00062 } else { 00063 $this->output( "no statistics available\n" ); 00064 } 00065 00066 $this->output( "\nImage cache\n" ); 00067 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) ); 00068 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) ); 00069 $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) ); 00070 $total = $hits + $misses; 00071 if ( $total ) { 00072 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); 00073 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) ); 00074 $this->output( sprintf( "updates: %-10d\n", $updates ) ); 00075 } else { 00076 $this->output( "no statistics available\n" ); 00077 } 00078 00079 $this->output( "\nDiff cache\n" ); 00080 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) ); 00081 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) ); 00082 $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) ); 00083 $total = $hits + $misses + $uncacheable; 00084 if ( $total ) { 00085 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); 00086 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) ); 00087 $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) ); 00088 } else { 00089 $this->output( "no statistics available\n" ); 00090 } 00091 } 00092 } 00093 00094 $maintClass = "ShowCacheStats"; 00095 require_once RUN_MAINTENANCE_IF_MAIN;