3 * This script makes several 'set', 'incr' and 'get' requests on every
4 * memcached server and shows a report.
11 $optionsWithArgs = array( 'i' );
13 require_once('commandLine.inc');
15 function microtime_float()
17 list($usec, $sec) = explode(" ", microtime());
18 return ((float)$usec +
(float)$sec);
22 #$wgDebugLogFile = '/dev/stdout';
24 if ( isset( $args[0] ) ) {
25 $wgMemCachedServers = array( $args[0] );
27 if ( isset( $options['i'] ) ) {
28 $iterations = $options['i'];
33 foreach ( $wgMemCachedServers as $server ) {
35 $mcc = new MemCachedClientforWiki( array('persistant' => true) );
36 $mcc->set_servers( array( $server ) );
40 $time_start=microtime_float();
41 for ( $i=1; $i<=$iterations; $i++
) {
42 if ( !is_null( $mcc->set( "test$i", $i ) ) ) {
47 for ( $i=1; $i<=$iterations; $i++
) {
48 if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
53 for ( $i=1; $i<=$iterations; $i++
) {
54 $value = $mcc->get( "test$i" );
55 if ( $value == $i*2 ) {
59 $exectime=microtime_float()-$time_start;
61 print "set: $set incr: $incr get: $get time: $exectime\n";