Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / showCacheStats.php
blobcd9768d4bb67afd8f1a51b190ff41b8867da6f9e
1 <?php
2 /**
3 * Show statistics from the cache.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Maintenance
24 require_once __DIR__ . '/Maintenance.php';
26 /**
27 * Maintenance script that shows statistics from the cache.
29 * @ingroup Maintenance
31 class ShowCacheStats extends Maintenance {
33 public function __construct() {
34 $this->mDescription = "Show statistics from the cache";
35 parent::__construct();
38 public function getDbType() {
39 return Maintenance::DB_NONE;
42 public function execute() {
43 global $wgMemc;
45 // Can't do stats if
46 if ( get_class( $wgMemc ) == 'EmptyBagOStuff' ) {
47 $this->error( "You are running EmptyBagOStuff, I can not provide any statistics.", true );
49 $session = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_with_session' ) ) );
50 $noSession = intval( $wgMemc->get( wfMemcKey( 'stats', 'request_without_session' ) ) );
51 $total = $session + $noSession;
52 if ( $total == 0 ) {
53 $this->error( "You either have no stats or the cache isn't running. Aborting.", true );
55 $this->output( "Requests\n" );
56 $this->output( sprintf( "with session: %-10d %6.2f%%\n", $session, $session / $total * 100 ) );
57 $this->output( sprintf( "without session: %-10d %6.2f%%\n", $noSession, $noSession / $total * 100 ) );
58 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
61 $this->output( "\nParser cache\n" );
62 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_hit' ) ) );
63 $expired = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_expired' ) ) );
64 $absent = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_absent' ) ) );
65 $stub = intval( $wgMemc->get( wfMemcKey( 'stats', 'pcache_miss_stub' ) ) );
66 $total = $hits + $expired + $absent + $stub;
67 if ( $total ) {
68 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
69 $this->output( sprintf( "expired: %-10d %6.2f%%\n", $expired, $expired / $total * 100 ) );
70 $this->output( sprintf( "absent: %-10d %6.2f%%\n", $absent, $absent / $total * 100 ) );
71 $this->output( sprintf( "stub threshold: %-10d %6.2f%%\n", $stub, $stub / $total * 100 ) );
72 $this->output( sprintf( "total: %-10d %6.2f%%\n", $total, 100 ) );
73 } else {
74 $this->output( "no statistics available\n" );
77 $this->output( "\nImage cache\n" );
78 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_hit' ) ) );
79 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_miss' ) ) );
80 $updates = intval( $wgMemc->get( wfMemcKey( 'stats', 'image_cache_update' ) ) );
81 $total = $hits + $misses;
82 if ( $total ) {
83 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
84 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
85 $this->output( sprintf( "updates: %-10d\n", $updates ) );
86 } else {
87 $this->output( "no statistics available\n" );
90 $this->output( "\nDiff cache\n" );
91 $hits = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_hit' ) ) );
92 $misses = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_cache_miss' ) ) );
93 $uncacheable = intval( $wgMemc->get( wfMemcKey( 'stats', 'diff_uncacheable' ) ) );
94 $total = $hits + $misses + $uncacheable;
95 if ( $total ) {
96 $this->output( sprintf( "hits: %-10d %6.2f%%\n", $hits, $hits / $total * 100 ) );
97 $this->output( sprintf( "misses: %-10d %6.2f%%\n", $misses, $misses / $total * 100 ) );
98 $this->output( sprintf( "uncacheable: %-10d %6.2f%%\n", $uncacheable, $uncacheable / $total * 100 ) );
99 } else {
100 $this->output( "no statistics available\n" );
105 $maintClass = "ShowCacheStats";
106 require_once RUN_MAINTENANCE_IF_MAIN;