+ $mccByServer[$server]->get( 'key' );
+ }
+ $this->output( "done\n" );
+ $this->output( "Single and batched operation profiling/test results:\n" );
+
+ $valueByKey = [];
+ for ( $i = 1; $i <= $iterations; $i++ ) {
+ $valueByKey["test$i"] = 'S' . str_pad( $i, 2048 );
+ }
+
+ foreach ( $mccByServer as $server => $mcc ) {
+ $this->output( str_pad( $server, $maxSrvLen ) . "\n" );
+ $this->benchmarkSingleKeyOps( $mcc, $valueByKey );
+ $this->benchmarkMultiKeyOpsImmediateBlocking( $mcc, $valueByKey );
+ $this->benchmarkMultiKeyOpsDeferredBlocking( $mcc, $valueByKey );
+ }
+ }
+
+ /**
+ * @param BagOStuff $mcc
+ * @param array $valueByKey
+ */
+ private function benchmarkSingleKeyOps( BagOStuff $mcc, array $valueByKey ) {
+ $add = 0;
+ $set = 0;
+ $incr = 0;
+ $get = 0;
+ $delete = 0;
+
+ $i = count( $valueByKey );
+ $keys = array_keys( $valueByKey );
+
+ // Clear out any old values
+ $mcc->deleteMulti( $keys );
+
+ $time_start = microtime( true );
+ foreach ( $keys as $key ) {
+ if ( $mcc->add( $key, $i ) ) {
+ $add++;
+ }
+ }
+ $addMs = intval( 1e3 * ( microtime( true ) - $time_start ) );
+
+ $time_start = microtime( true );
+ foreach ( $keys as $key ) {
+ if ( $mcc->set( $key, $i ) ) {
+ $set++;
+ }
+ }
+ $setMs = intval( 1e3 * ( microtime( true ) - $time_start ) );
+
+ $time_start = microtime( true );
+ foreach ( $keys as $key ) {
+ if ( !is_null( $mcc->incr( $key, $i ) ) ) {
+ $incr++;