diff options
Diffstat (limited to 'scripts/scalability/test_controller/utils.py')
-rw-r--r-- | scripts/scalability/test_controller/utils.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/scalability/test_controller/utils.py b/scripts/scalability/test_controller/utils.py new file mode 100644 index 00000000..ebe55571 --- /dev/null +++ b/scripts/scalability/test_controller/utils.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import base64 +import errno +import os +import random + + +def payload(size): + random.seed(1337) # same seed to avoid different bench results + payload_bytes = bytearray(random.getrandbits(8) for _ in xrange(size)) + # encode as base64 to avoid ascii encode/decode errors + return base64.b64encode(payload_bytes)[:size] # remove b64 overhead + + +def mkdir_p(path): + try: + os.makedirs(path) + except OSError as exc: # Python >2.5 + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise |