Last active
August 29, 2015 14:05
-
-
Save redbo/ebc2a15efb69fcee56b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import os | |
import uuid | |
import random | |
from swift.container.backend import ContainerBroker | |
from swift.common.utils import normalize_timestamp | |
INSERT_COUNT = 100 | |
RECORD_COUNT = 1000 | |
def rand_str(): | |
return str(uuid.uuid4()) | |
def rand_timestamp(): | |
return normalize_timestamp(random.randint(0, 1000000000000)) | |
try: | |
os.unlink('/tmp/something.db') | |
except Exception: | |
pass | |
x = ContainerBroker('/tmp/something.db', account='a', container='c') | |
x.initialize(rand_timestamp(), 0) | |
start = time.time() | |
for _ in xrange(INSERT_COUNT): | |
records = [{'name': rand_str(), 'created_at': rand_timestamp(), 'size': 0, | |
'content_type': 'text/plain', 'etag': 'd41d8cd98f00b204e9800998ecf8427e', | |
'deleted': 0, | |
'storage_policy_index': 0} for _ in xrange(RECORD_COUNT)] | |
x.merge_items(records) | |
print time.time() - start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment