No point in fetching the result in Database::unlock() if we're not using it anyway.
[lhc/web/wiklou.git] / maintenance / mctest.php
1 <?php
2 /**
3 * $Id$
4 * @file
5 * @ingroup Maintenance
6 */
7
8 $optionsWithArgs = array( 'i' );
9
10 require_once('commandLine.inc');
11
12 function microtime_float()
13 {
14 list($usec, $sec) = explode(" ", microtime());
15 return ((float)$usec + (float)$sec);
16 }
17
18
19 #$wgDebugLogFile = '/dev/stdout';
20
21 if ( isset( $args[0] ) ) {
22 $wgMemCachedServers = array( $args[0] );
23 }
24 if ( isset( $options['i'] ) ) {
25 $iterations = $options['i'];
26 } else {
27 $iterations = 100;
28 }
29
30 foreach ( $wgMemCachedServers as $server ) {
31 print "$server ";
32 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
33 $mcc->set_servers( array( $server ) );
34 $set = 0;
35 $incr = 0;
36 $get = 0;
37 $time_start=microtime_float();
38 for ( $i=1; $i<=$iterations; $i++ ) {
39 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
40 $set++;
41 }
42 }
43
44 for ( $i=1; $i<=$iterations; $i++ ) {
45 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
46 $incr++;
47 }
48 }
49
50 for ( $i=1; $i<=$iterations; $i++ ) {
51 $value = $mcc->get( "test$i" );
52 if ( $value == $i*2 ) {
53 $get++;
54 }
55 }
56 $exectime=microtime_float()-$time_start;
57
58 print "set: $set incr: $incr get: $get time: $exectime\n";
59 }
60
61
62