X-Git-Url: http://git.vrable.net/?p=bluesky.git;a=blobdiff_plain;f=cloudbench%2Fcloudtest.py;fp=cloudbench%2Fcloudtest.py;h=07556882d1a2363a3e015663a37b513bc8e95f5f;hp=0000000000000000000000000000000000000000;hb=4a16bafc74f36e1314a722544612ad7ac6a6cd05;hpb=9d32f47c84c4b8aae2ec6fd63d1a4f008228e82f diff --git a/cloudbench/cloudtest.py b/cloudbench/cloudtest.py new file mode 100755 index 0000000..0755688 --- /dev/null +++ b/cloudbench/cloudtest.py @@ -0,0 +1,73 @@ +#!/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()