]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/mctest.php
MediaWiki 1.11.0-scripts
[autoinstalls/mediawiki.git] / maintenance / mctest.php
1 <?php
2 /* $Id: mctest.php 23531 2007-06-29 01:19:14Z simetrical $ */
3
4 $optionsWithArgs = array( 'i' );
5
6 require_once('commandLine.inc');
7
8 function microtime_float()
9 {
10    list($usec, $sec) = explode(" ", microtime());
11    return ((float)$usec + (float)$sec);
12 }
13
14
15 #$wgDebugLogFile = '/dev/stdout';
16
17 if ( isset( $args[0] ) ) {
18         $wgMemCachedServers = array( $args[0] );
19 }
20 if ( isset( $options['i'] ) ) {
21         $iterations = $options['i'];
22 } else {
23         $iterations = 100;
24 }
25
26 foreach ( $wgMemCachedServers as $server ) {
27         print "$server ";
28         $mcc = new MemCachedClientforWiki( array('persistant' => true) );
29         $mcc->set_servers( array( $server ) );
30         $set = 0;
31         $incr = 0;
32         $get = 0;
33         $time_start=microtime_float();
34         for ( $i=1; $i<=$iterations; $i++ ) {
35                 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
36                         $set++;
37                 }
38         }
39
40         for ( $i=1; $i<=$iterations; $i++ ) {
41                 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
42                         $incr++;
43                 }
44         }
45
46         for ( $i=1; $i<=$iterations; $i++ ) {
47                 $value = $mcc->get( "test$i" );
48                 if ( $value == $i*2 ) {
49                         $get++;
50                 }
51         }
52         $exectime=microtime_float()-$time_start;
53
54         print "set: $set   incr: $incr   get: $get time: $exectime\n";
55 }
56
57
58