00001 <?php
00023 require_once( dirname(__FILE__) . '/Maintenance.php' );
00024
00025 class CacheStats extends Maintenance {
00026
00027 public function __construct() {
00028 $this->mDescription = "Show statistics from the cache";
00029 }
00030
00031 public function execute() {
00032 global $wgMemc;
00033
00034
00035 if( get_class( $wgMemc ) == 'FakeMemCachedClient' ) {
00036 $this->error( "You are running FakeMemCachedClient, I can not provide any statistics.", true );
00037 }
00038 $session = intval($wgMemc->get(wfMemcKey('stats','request_with_session')));
00039 $noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session')));
00040 $total = $session + $noSession;
00041 if ( $total == 0 ) {
00042 $this->error( "You either have no stats or the cache isn't running. Aborting.", true );
00043 }
00044 $this->output( "Requests\n" );
00045 $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session/$total*100 ) );
00046 $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession/$total*100 ) );
00047 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
00048
00049
00050 $this->output( "\nParser cache\n" );
00051 $hits = intval($wgMemc->get(wfMemcKey('stats','pcache_hit')));
00052 $invalid = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_invalid')));
00053 $expired = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_expired')));
00054 $absent = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_absent')));
00055 $stub = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_stub')));
00056 $total = $hits + $invalid + $expired + $absent + $stub;
00057 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) );
00058 $this->output( sprintf( "invalid: %-10d %6.2f%%\n", $invalid, $invalid/$total*100 ) );
00059 $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired/$total*100 ) );
00060 $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent/$total*100 ) );
00061 $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub/$total*100 ) );
00062 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
00063
00064 $hits = intval($wgMemc->get(wfMemcKey('stats','image_cache_hit')));
00065 $misses = intval($wgMemc->get(wfMemcKey('stats','image_cache_miss')));
00066 $updates = intval($wgMemc->get(wfMemcKey('stats','image_cache_update')));
00067 $total = $hits + $misses;
00068 $this->output("\nImage cache\n");
00069 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) );
00070 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ) );
00071 $this->output( sprintf( "updates: %-10d\n", $updates ) );
00072
00073 $hits = intval($wgMemc->get(wfMemcKey('stats','diff_cache_hit')));
00074 $misses = intval($wgMemc->get(wfMemcKey('stats','diff_cache_miss')));
00075 $uncacheable = intval($wgMemc->get(wfMemcKey('stats','diff_uncacheable')));
00076 $total = $hits + $misses + $uncacheable;
00077 $this->output("\nDiff cache\n");
00078 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ) );
00079 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ) );
00080 $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable/$total*100 ) );
00081 }
00082 }
00083
00084 $maintClass = "CacheStats";
00085 require_once( DO_MAINTENANCE );
00086
00087
00088
00089