3 * This script makes several 'set', 'incr' and 'get' requests on every
4 * memcached server and shows a report.
10 $optionsWithArgs = array( 'i' );
12 require_once('commandLine.inc');
14 function microtime_float()
16 list($usec, $sec) = explode(" ", microtime());
17 return ((float)$usec +
(float)$sec);
21 #$wgDebugLogFile = '/dev/stdout';
23 if ( isset( $args[0] ) ) {
24 $wgMemCachedServers = array( $args[0] );
26 if ( isset( $options['i'] ) ) {
27 $iterations = $options['i'];
32 foreach ( $wgMemCachedServers as $server ) {
34 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
35 $mcc->set_servers( array( $server ) );
39 $time_start=microtime_float();
40 for ( $i=1; $i<=$iterations; $i++
) {
41 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
46 for ( $i=1; $i<=$iterations; $i++
) {
47 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
52 for ( $i=1; $i<=$iterations; $i++
) {
53 $value = $mcc->get( "test$i" );
54 if ( $value == $i*2 ) {
58 $exectime=microtime_float()-$time_start;
60 print "set: $set incr: $incr get: $get time: $exectime\n";