r83534 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83533‎ | r83534 | r83535 >
Date:18:01, 8 March 2011
Author:ialex
Status:ok
Tags:
Comment:
* Update class name: FakeMemCachedClient -> EmptyBagOStuff
* Don't show "Division by zero" warnings when there's no statistics for cache hits
Modified paths:
  • /trunk/phase3/maintenance/stats.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/stats.php
@@ -37,8 +37,8 @@
3838 global $wgMemc;
3939
4040 // Can't do stats if
41 - if ( get_class( $wgMemc ) == 'FakeMemCachedClient' ) {
42 - $this->error( "You are running FakeMemCachedClient, I can not provide any statistics.", true );
 41+ if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) {
 42+ $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true );
4343 }
4444 $session = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_with_session' ) ) );
4545 $noSession = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_without_session' ) ) );
@@ -59,30 +59,42 @@
6060 $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) );
6161 $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) );
6262 $total = $hits + $invalid + $expired + $absent + $stub;
63 - $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
64 - $this->output( sprintf( "invalid: %-10d %6.2f%%\n", $invalid, $invalid / $total * 100 ) );
65 - $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
66 - $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
67 - $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
68 - $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
 63+ if ( $total ) {
 64+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
 65+ $this->output( sprintf( "invalid: %-10d %6.2f%%\n", $invalid, $invalid / $total * 100 ) );
 66+ $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
 67+ $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
 68+ $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
 69+ $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
 70+ } else {
 71+ $this->output( "no statistics available\n" );
 72+ }
6973
 74+ $this->output( "\nImage cache\n" );
7075 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) );
7176 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) );
7277 $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) );
7378 $total = $hits + $misses;
74 - $this->output( "\nImage cache\n" );
75 - $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
76 - $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
77 - $this->output( sprintf( "updates: %-10d\n", $updates ) );
 79+ if ( $total ) {
 80+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
 81+ $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
 82+ $this->output( sprintf( "updates: %-10d\n", $updates ) );
 83+ } else {
 84+ $this->output( "no statistics available\n" );
 85+ }
7886
 87+ $this->output( "\nDiff cache\n" );
7988 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) );
8089 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) );
8190 $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) );
8291 $total = $hits + $misses + $uncacheable;
83 - $this->output( "\nDiff cache\n" );
84 - $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
85 - $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
86 - $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
 92+ if ( $total ) {
 93+ $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
 94+ $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
 95+ $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
 96+ } else {
 97+ $this->output( "no statistics available\n" );
 98+ }
8799 }
88100 }
89101

Status & tagging log