diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
commit | 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch) | |
tree | af68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /maintenance/mctest.php | |
parent | af4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff) |
Update to MediaWiki 1.22.0
Diffstat (limited to 'maintenance/mctest.php')
-rw-r--r-- | maintenance/mctest.php | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/maintenance/mctest.php b/maintenance/mctest.php index 469feca2..eda101e7 100644 --- a/maintenance/mctest.php +++ b/maintenance/mctest.php @@ -22,7 +22,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script that makes several 'set', 'incr' and 'get' requests @@ -34,7 +34,7 @@ class mcTest extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every" - . " memcached server and shows a report"; + . " memcached server and shows a report"; $this->addOption( 'i', 'Number of iterations', false, true ); $this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true ); $this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false ); @@ -54,15 +54,22 @@ class mcTest extends Maintenance { $servers = array( $this->getArg() ); } elseif ( $wgMainCacheType === CACHE_MEMCACHED ) { global $wgMemCachedServers; - $servers = $wgMemCachedServers ; + $servers = $wgMemCachedServers; } elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) { $servers = $wgObjectCaches[$wgMainCacheType]['servers']; } else { $this->error( "MediaWiki isn't configured for Memcached usage", 1 ); } + # find out the longest server string to nicely align output later on + $maxSrvLen = $servers ? max( array_map( 'strlen', $servers ) ) : 0; + foreach ( $servers as $server ) { - $this->output( $server . " ", $server ); + $this->output( + str_pad( $server, $maxSrvLen ), + $server # output channel + ); + $mcc = new MemCachedClientforWiki( array( 'persistant' => true, 'timeout' => $wgMemCachedTimeout @@ -73,7 +80,7 @@ class mcTest extends Maintenance { $get = 0; $time_start = $this->microtime_float(); for ( $i = 1; $i <= $iterations; $i++ ) { - if ( !is_null( $mcc->set( "test$i", $i ) ) ) { + if ( $mcc->set( "test$i", $i ) ) { $set++; } } @@ -90,7 +97,7 @@ class mcTest extends Maintenance { } $exectime = $this->microtime_float() - $time_start; - $this->output( "set: $set incr: $incr get: $get time: $exectime", $server ); + $this->output( " set: $set incr: $incr get: $get time: $exectime", $server ); } } @@ -105,4 +112,4 @@ class mcTest extends Maintenance { } $maintClass = "mcTest"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN; |