MediaWiki
REL1_24
|
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( 00059 "expired: %-10d %6.2f%%\n", 00060 $expired, 00061 $expired / $total * 100 00062 ) ); 00063 $this->output( sprintf( 00064 "absent: %-10d %6.2f%%\n", 00065 $absent, 00066 $absent / $total * 100 00067 ) ); 00068 $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) ); 00069 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) ); 00070 } else { 00071 $this->output( "no statistics available\n" ); 00072 } 00073 00074 $this->output( "\nImage cache\n" ); 00075 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) ); 00076 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) ); 00077 $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) ); 00078 $total = $hits + $misses; 00079 if ( $total ) { 00080 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); 00081 $this->output( sprintf( 00082 "misses: %-10d %6.2f%%\n", 00083 $misses, 00084 $misses / $total * 100 00085 ) ); 00086 $this->output( sprintf( "updates: %-10d\n", $updates ) ); 00087 } else { 00088 $this->output( "no statistics available\n" ); 00089 } 00090 00091 $this->output( "\nDiff cache\n" ); 00092 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) ); 00093 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) ); 00094 $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) ); 00095 $total = $hits + $misses + $uncacheable; 00096 if ( $total ) { 00097 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) ); 00098 $this->output( sprintf( 00099 "misses: %-10d %6.2f%%\n", 00100 $misses, 00101 $misses / $total * 100 00102 ) ); 00103 $this->output( sprintf( 00104 "uncacheable: %-10d %6.2f%%\n", 00105 $uncacheable, 00106 $uncacheable / $total * 100 00107 ) ); 00108 } else { 00109 $this->output( "no statistics available\n" ); 00110 } 00111 } 00112 } 00113 00114 $maintClass = "ShowCacheStats"; 00115 require_once RUN_MAINTENANCE_IF_MAIN;