00001 <?php
00011 $optionsWithArgs = array( 'i' );
00012
00013 require_once('commandLine.inc');
00014
00015 function microtime_float()
00016 {
00017 list($usec, $sec) = explode(" ", microtime());
00018 return ((float)$usec + (float)$sec);
00019 }
00020
00021
00022 #$wgDebugLogFile = '/dev/stdout';
00023
00024 if ( isset( $args[0] ) ) {
00025 $wgMemCachedServers = array( $args[0] );
00026 }
00027 if ( isset( $options['i'] ) ) {
00028 $iterations = $options['i'];
00029 } else {
00030 $iterations = 100;
00031 }
00032
00033 foreach ( $wgMemCachedServers as $server ) {
00034 print "$server ";
00035 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
00036 $mcc->set_servers( array( $server ) );
00037 $set = 0;
00038 $incr = 0;
00039 $get = 0;
00040 $time_start=microtime_float();
00041 for ( $i=1; $i<=$iterations; $i++ ) {
00042 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
00043 $set++;
00044 }
00045 }
00046
00047 for ( $i=1; $i<=$iterations; $i++ ) {
00048 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
00049 $incr++;
00050 }
00051 }
00052
00053 for ( $i=1; $i<=$iterations; $i++ ) {
00054 $value = $mcc->get( "test$i" );
00055 if ( $value == $i*2 ) {
00056 $get++;
00057 }
00058 }
00059 $exectime=microtime_float()-$time_start;
00060
00061 print "set: $set incr: $incr get: $get time: $exectime\n";
00062 }
00063
00064
00065