From: Tim Starling Date: Sun, 19 Jun 2005 03:05:51 +0000 (+0000) Subject: stats changes ported from 1.4 X-Git-Tag: 1.5.0beta1~149 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=ad01e39c51e0ff63d139ed48257bbacba11a1a29;p=lhc%2Fweb%2Fwiklou.git stats changes ported from 1.4 --- 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_pcache_stats.php deleted file mode 100644 index 9cb25f50f6..0000000000 --- a/maintenance/clear_pcache_stats.php +++ /dev/null @@ -1,29 +0,0 @@ -delete($key) ) { - print "deleted\n"; - } else { - print "FAILED\n"; - }*/ - $wgMemc->delete($key); -} -?> \ No newline at end of file diff --git a/maintenance/clear_stats.php b/maintenance/clear_stats.php new file mode 100644 index 0000000000..278c609c86 --- /dev/null +++ b/maintenance/clear_stats.php @@ -0,0 +1,25 @@ +delete($key) ) { + print "deleted\n"; + } else { + print "FAILED\n"; + }*/ + $wgMemc->delete($key); +} +?> diff --git a/maintenance/pcache_stats.php b/maintenance/pcache_stats.php deleted file mode 100644 index 19497b125a..0000000000 --- a/maintenance/pcache_stats.php +++ /dev/null @@ -1,20 +0,0 @@ -get("$wgDBname:stats:pcache_hit")); -$invalid = intval($wgMemc->get("$wgDBname:stats:pcache_miss_invalid")); -$expired = intval($wgMemc->get("$wgDBname:stats:pcache_miss_expired")); -$absent = intval($wgMemc->get("$wgDBname:stats:pcache_miss_absent")); -$total = $hits + $invalid + $expired + $absent; -printf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ); -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 diff --git a/maintenance/stats.php b/maintenance/stats.php new file mode 100644 index 0000000000..a194671cf3 --- /dev/null +++ b/maintenance/stats.php @@ -0,0 +1,24 @@ +get("$wgDBname:stats:pcache_hit")); +$invalid = intval($wgMemc->get("$wgDBname:stats:pcache_miss_invalid")); +$expired = intval($wgMemc->get("$wgDBname:stats:pcache_miss_expired")); +$absent = intval($wgMemc->get("$wgDBname:stats:pcache_miss_absent")); +$total = $hits + $invalid + $expired + $absent; +printf( "hits: %-10d %6.2f%%\n", $hits, $hits/$total*100 ); +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 ); + +$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 ); + +?>