if __name__ == '__main__': # Run a benchmark! from riak import RiakClient import riak.benchmark as benchmark client = RiakClient(protocol='pbc') bkeys = [('multiget', str(key)) for key in xrange(10000)] data = open(__file__).read() print "Benchmarking multiget:" print " CPUs: {0}".format(cpu_count()) print " Threads: {0}".format(POOL_SIZE) print " Keys: {0}".format(len(bkeys)) print with benchmark.measure() as b: with b.report('populate'): for bucket, key in bkeys: client.bucket(bucket).new(key, encoded_data=data, content_type='text/plain' ).store() for b in benchmark.measure_with_rehearsal(): client.protocol = 'http' with b.report('http seq'): for bucket, key in bkeys: client.bucket(bucket).get(key) with b.report('http multi'): multiget(client, bkeys) client.protocol = 'pbc'