4 $optionsWithArgs = array( 'i' );
6 require_once('commandLine.inc');
8 #$wgDebugLogFile = '/dev/stdout';
10 if ( isset( $args[0] ) ) {
11 $wgMemCachedServers = array( $args[0] );
13 $wgMemCachedServers[] = 'localhost';
15 if ( isset( $options['i'] ) ) {
16 $iterations = $options['i'];
21 foreach ( $wgMemCachedServers as $server ) {
23 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
24 $mcc->set_servers( array( $server ) );
28 $time_start=microtime_float();
29 for ( $i=1; $i<=$iterations; $i++
) {
30 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
35 for ( $i=1; $i<=$iterations; $i++
) {
36 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
41 for ( $i=1; $i<=$iterations; $i++
) {
42 $value = $mcc->get( "test$i" );
43 if ( $value == $i*2 ) {
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);