stats changes ported from 1.4
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 19 Jun 2005 03:05:51 +0000 (03:05 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 19 Jun 2005 03:05:51 +0000 (03:05 +0000)
includes/GlobalFunctions.php
includes/Image.php
includes/ParserCache.php
maintenance/clear_pcache_stats.php [deleted file]
maintenance/clear_stats.php [new file with mode: 0644]
maintenance/pcache_stats.php [deleted file]
maintenance/stats.php [new file with mode: 0644]

index 5873970..6884cff 100644 (file)
@@ -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 );
+       }
+}
+
 ?>
index 3194ab2..2922312 100644 (file)
@@ -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;
index b156ccc..e283367 100644 (file)
@@ -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 (file)
index 9cb25f5..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * @package MediaWiki
- * @subpackage Maintenance
- */
-
-/** */
-require_once('commandLine.inc');
-
-foreach ( $wgLocalDatabases as $db ) {
-       noisyDelete("$db:stats:pcache_hit");
-       noisyDelete("$db:stats:pcache_miss_invalid");
-       noisyDelete("$db:stats:pcache_miss_expired");
-       noisyDelete("$db:stats:pcache_miss_absent");
-}
-
-/** @todo document */
-function noisyDelete( $key ) {
-       global $wgMemc;
-       /*
-       print "$key ";
-       if ( $wgMemc->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 (file)
index 0000000..278c609
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+require_once('commandLine.inc');
+
+foreach ( $wgLocalDatabases as $db ) {
+       noisyDelete("$db:stats:pcache_hit");
+       noisyDelete("$db:stats:pcache_miss_invalid");
+       noisyDelete("$db:stats:pcache_miss_expired");
+       noisyDelete("$db:stats:pcache_miss_absent");
+       noisyDelete("$db:stats:image_cache_hit");
+       noisyDelete("$db:stats:image_cache_miss");
+       noisyDelete("$db:stats:image_cache_update");
+}
+
+function noisyDelete( $key ) {
+       global $wgMemc;
+       /*
+       print "$key ";
+       if ( $wgMemc->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 (file)
index 19497b1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-/**
- * @package MediaWiki
- * @subpackage Maintenance
- */
-
-/** */
-require_once('commandLine.inc');
-
-$hits = intval($wgMemc->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 (file)
index 0000000..a194671
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+require_once('commandLine.inc');
+
+$hits = intval($wgMemc->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 );
+
+?>