(bug 4860) Expose Title->userCan() as Hooks
[lhc/web/wiklou.git] / maintenance / mctest.php
1 <?php
2 /* $Id$ */
3
4 $optionsWithArgs = array( 'i' );
5
6 require_once('commandLine.inc');
7
8 #$wgDebugLogFile = '/dev/stdout';
9
10 if ( isset( $args[0] ) ) {
11 $wgMemCachedServers = array( $args[0] );
12 } else {
13 $wgMemCachedServers[] = 'localhost';
14 }
15 if ( isset( $options['i'] ) ) {
16 $iterations = $options['i'];
17 } else {
18 $iterations = 100;
19 }
20
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++;
32 }
33 }
34
35 for ( $i=1; $i<=$iterations; $i++ ) {
36 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
37 $incr++;
38 }
39 }
40
41 for ( $i=1; $i<=$iterations; $i++ ) {
42 $value = $mcc->get( "test$i" );
43 if ( $value == $i*2 ) {
44 $get++;
45 }
46 }
47 $exectime=microtime_float()-$time_start;
48
49 print "set: $set incr: $incr get: $get time: $exectime\n";
50 }
51
52 function microtime_float()
53 {
54 list($usec, $sec) = explode(" ", microtime());
55 return ((float)$usec + (float)$sec);
56 }
57
58
59 ?>