* Make some more messages '*-summary' customizeable through Special:Allmessages or...
[lhc/web/wiklou.git] / maintenance / mctest.php
1 <?php
2 /* $Id$ */
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 } else {
20 $wgMemCachedServers[] = 'localhost';
21 }
22 if ( isset( $options['i'] ) ) {
23 $iterations = $options['i'];
24 } else {
25 $iterations = 100;
26 }
27
28 foreach ( $wgMemCachedServers as $server ) {
29 print "$server ";
30 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
31 $mcc->set_servers( array( $server ) );
32 $set = 0;
33 $incr = 0;
34 $get = 0;
35 $time_start=microtime_float();
36 for ( $i=1; $i<=$iterations; $i++ ) {
37 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
38 $set++;
39 }
40 }
41
42 for ( $i=1; $i<=$iterations; $i++ ) {
43 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
44 $incr++;
45 }
46 }
47
48 for ( $i=1; $i<=$iterations; $i++ ) {
49 $value = $mcc->get( "test$i" );
50 if ( $value == $i*2 ) {
51 $get++;
52 }
53 }
54 $exectime=microtime_float()-$time_start;
55
56 print "set: $set incr: $incr get: $get time: $exectime\n";
57 }
58
59
60 ?>