From ad01e39c51e0ff63d139ed48257bbacba11a1a29 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 19 Jun 2005 03:05:51 +0000 Subject: [PATCH] stats changes ported from 1.4 --- includes/GlobalFunctions.php | 9 +++++++++ includes/Image.php | 5 +++++ includes/ParserCache.php | 16 ++++------------ ...{clear_pcache_stats.php => clear_stats.php} | 12 ++++-------- maintenance/{pcache_stats.php => stats.php} | 18 +++++++++++------- 5 files changed, 33 insertions(+), 27 deletions(-) rename maintenance/{clear_pcache_stats.php => clear_stats.php} (76%) rename maintenance/{pcache_stats.php => stats.php} (61%) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 58739704ef..6884cff707 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1248,4 +1248,13 @@ function wfMkdirParents( $fullDir, $mode ) { return true; } + +function wfIncrStats( $key ) { + global $wgDBname, $wgMemc; + $key = "$wgDBname:stats:$key"; + if ( is_null( $wgMemc->incr( $key ) ) ) { + $wgMemc->add( $key, 1 ); + } +} + ?> diff --git a/includes/Image.php b/includes/Image.php index 3194ab2b0b..2922312030 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -152,6 +152,11 @@ class Image $this->imagePath = $this->getFullPath(); } } + if ( $this->dataLoaded ) { + wfIncrStats( 'image_cache_hit' ); + } else { + wfIncrStats( 'image_cache_miss' ); + } wfProfileOut( $fname ); return $this->dataLoaded; diff --git a/includes/ParserCache.php b/includes/ParserCache.php index b156ccc7de..e283367c2a 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -47,21 +47,21 @@ class ParserCache { $touched = $article->mTouched; if ( !$canCache || $value->expired( $touched ) ) { if ( !$canCache ) { - $this->incrStats( "pcache_miss_invalid" ); + wfIncrStats( "pcache_miss_invalid" ); wfDebug( "Invalid cached redirect, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); } else { - $this->incrStats( "pcache_miss_expired" ); + wfIncrStats( "pcache_miss_expired" ); wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" ); } $this->mMemc->delete( $key ); $value = false; } else { - $this->incrStats( "pcache_hit" ); + wfIncrStats( "pcache_hit" ); } } else { wfDebug( "Parser cache miss.\n" ); - $this->incrStats( "pcache_miss_absent" ); + wfIncrStats( "pcache_miss_absent" ); $value = false; } @@ -83,14 +83,6 @@ class ParserCache { } $this->mMemc->set( $key, $parserOutput, $expire ); } - - function incrStats( $key ) { - global $wgDBname, $wgMemc; - $key = "$wgDBname:stats:$key"; - if ( is_null( $wgMemc->incr( $key ) ) ) { - $wgMemc->add( $key, 1 ); - } - } } diff --git a/maintenance/clear_pcache_stats.php b/maintenance/clear_stats.php similarity index 76% rename from maintenance/clear_pcache_stats.php rename to maintenance/clear_stats.php index 9cb25f50f6..278c609c86 100644 --- a/maintenance/clear_pcache_stats.php +++ b/maintenance/clear_stats.php @@ -1,10 +1,4 @@ delete($key); } -?> \ No newline at end of file +?> diff --git a/maintenance/pcache_stats.php b/maintenance/stats.php similarity index 61% rename from maintenance/pcache_stats.php rename to maintenance/stats.php index 19497b125a..a194671cf3 100644 --- a/maintenance/pcache_stats.php +++ b/maintenance/stats.php @@ -1,10 +1,4 @@ get("$wgDBname:stats:pcache_hit")); @@ -17,4 +11,14 @@ printf( "invalid: %-10d %6.2f%%\n", $invalid, $invalid/$total*100 ); printf( "expired: %-10d %6.2f%%\n", $expired, $expired/$total*100 ); printf( "absent: %-10d %6.2f%%\n", $absent, $absent/$total*100 ); printf( "total: %-10d %6.2f%%\n", $total, 100 ); -?> \ No newline at end of file + +$hits = intval($wgMemc->get("$wgDBname:stats:image_cache_hit")); +$misses = intval($wgMemc->get("$wgDBname:stats:image_cache_miss")); +$updates = intval($wgMemc->get("$wgDBname:stats:image_cache_update")); +$total = $hits + $misses; +print("\nImage cache\n"); +printf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ); +printf( "misses: %-10d %6.2f%%\n", $misses, $misses/$total*100 ); +printf( "updates: %-10d\n", $updates ); + +?> -- 2.20.1