+++ /dev/null
-#!/usr/bin/python
-#
-# Run a series of simple test requests against S3 for gathering some basic
-# performance numbers.
-
-import boto, time
-from boto.s3.connection import SubdomainCallingFormat
-from boto.s3.key import Key
-import azure
-
-BUCKET_NAME = 'mvrable-benchmark'
-SIZES = [64, 4096, 32 << 10, 256 << 10, 1 << 20, 4 << 20, 32 << 20]
-
-class S3TestConnection:
- def __init__(self):
- self.conn = boto.connect_s3(is_secure=False,
- calling_format=SubdomainCallingFormat())
- self.bucket = self.conn.get_bucket(BUCKET_NAME)
-
- def put_object(self, name, size):
- buf = 'A' * size
- k = Key(self.bucket, name)
- start_time = time.time()
- k.set_contents_from_string(buf)
- print "%s: %f" % (name, time.time() - start_time)
-
- def get_object(self, name, size):
- k = Key(self.bucket, name)
- start_time = time.time()
- buf = k.get_contents_as_string()
- print "%s: %f" % (name, time.time() - start_time)
-
-class AzureTestConnection:
- def __init__(self):
- self.conn = azure.Connection()
-
- def put_object(self, name, size):
- buf = 'A' * size
- start_time = time.time()
- self.conn.make_request('/benchmark/' + name, 'PUT', buf,
- {'x-ms-blob-type': 'BlockBlob'})
- print "%s: %f" % (name, time.time() - start_time)
-
- def get_object(self, name, size):
- start_time = time.time()
- self.conn.make_request('/benchmark/' + name, 'GET')
- print "%s: %f" % (name, time.time() - start_time)
-
-def run_test():
- print "==== S3 ===="
- c = S3TestConnection()
- for repeat in range(4):
- for size in SIZES:
- c.put_object('file-%d-%d' % (size, repeat), size)
-
- c = S3TestConnection()
- for repeat in range(4):
- for size in SIZES:
- c.get_object('file-%d-%d' % (size, repeat), size)
-
- print "==== AZURE ===="
- c = AzureTestConnection()
- for repeat in range(4):
- for size in SIZES:
- c.put_object('file-%d-%d' % (size, repeat), size)
-
- c = AzureTestConnection()
- for repeat in range(4):
- for size in SIZES:
- c.get_object('file-%d-%d' % (size, repeat), size)
-
-if __name__ == '__main__':
- run_test()