SpecialContributions: fixed style, fixed sloppy handling of empty query results,...
[mediawiki.git] / maintenance / mctest.php
blob7deaa0770634e4f649a52ba772b7b33cb88c628d
1 <?php
2 /* $Id$ */
4 $optionsWithArgs = array( 'i' );
6 require_once('commandLine.inc');
8 #$wgDebugLogFile = '/dev/stdout';
10 if ( isset( $args[0] ) ) {
11 $wgMemCachedServers = array( $args[0] );
12 } else {
13 $wgMemCachedServers[] = 'localhost';
15 if ( isset( $options['i'] ) ) {
16 $iterations = $options['i'];
17 } else {
18 $iterations = 100;
21 foreach ( $wgMemCachedServers as $server ) {
22 print "$server ";
23 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
24 $mcc->set_servers( array( $server ) );
25 $set = 0;
26 $incr = 0;
27 $get = 0;
28 $time_start=microtime_float();
29 for ( $i=1; $i<=$iterations; $i++ ) {
30 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
31 $set++;
35 for ( $i=1; $i<=$iterations; $i++ ) {
36 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
37 $incr++;
41 for ( $i=1; $i<=$iterations; $i++ ) {
42 $value = $mcc->get( "test$i" );
43 if ( $value == $i*2 ) {
44 $get++;
47 $exectime=microtime_float()-$time_start;
49 print "set: $set incr: $incr get: $get time: $exectime\n";
52 function microtime_float()
54 list($usec, $sec) = explode(" ", microtime());
55 return ((float)$usec + (float)$sec);