# PY2 -> buffer # PY3 -> memoryview # (rationale: a lot of functions do not accept memoryview on py2 - e.g. adler32) def xbuffer(obj, offset=0, size=None): if size is None: size = len(obj) - offset if PY2: return buffer(obj, offset, size) else: return memoryview(obj)[offset : offset + size] tmpf = None blksize = 2 * 1024 * 1024 # XXX hardcoded filesize = 512 * 1024 * 1024 nulladler32 = nulladler32_bysize(filesize) ffadler32 = ffadler32_bysize(filesize) # setup whole-hole OS file def setup_module(): global tmpf tmpf = NamedTemporaryFile(prefix="hole.", delete=False) tmpf.close() fd = os.open(tmpf.name, O_RDWR | O_TRUNC) ftruncate(fd, filesize) close(fd) def teardown_module():
# Wendelin.bigfile | benchmarks for zodb backend # # TODO text from wendelin.bigfile.file_zodb import ZBigFile from wendelin.lib.mem import memset from wendelin.lib.testing import getTestDB, Adler32, nulladler32_bysize, ffadler32_bysize from wendelin.lib.zodb import dbclose import transaction testdb = None from wendelin.bigfile.tests.bench_0virtmem import filesize, blksize # to get comparable timings blen = filesize // blksize nulladler32 = nulladler32_bysize(blen * blksize) ffadler32 = ffadler32_bysize(blen * blksize) def setup_module(): global testdb testdb = getTestDB() testdb.setup() root = testdb.dbopen() root['zfile'] = ZBigFile(blksize) transaction.commit() dbclose(root) def teardown_module(): testdb.teardown()