mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
use zeros for benchmarks
This commit is contained in:
parent
be257728ca
commit
e41dc6e96f
2 changed files with 5 additions and 2 deletions
|
@ -453,9 +453,10 @@ def measurement_run(repo, path):
|
|||
def test_files(path, count, size, random):
|
||||
path = os.path.join(path, 'borg-test-data')
|
||||
os.makedirs(path)
|
||||
z_buff = None if random else memoryview(zeros)[:size] if size <= len(zeros) else b'\0' * size
|
||||
for i in range(count):
|
||||
fname = os.path.join(path, 'file_%d' % i)
|
||||
data = b'\0' * size if not random else os.urandom(size)
|
||||
data = z_buff if not random else os.urandom(size)
|
||||
with SyncFile(fname, binary=True) as fd: # used for posix_fadvise's sake
|
||||
fd.write(data)
|
||||
yield path
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
import pytest
|
||||
|
||||
from .archiver import changedir, cmd
|
||||
from ..constants import zeros
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -34,12 +35,13 @@ def repo(request, cmd, repo_url):
|
|||
@pytest.fixture(scope='session', params=["zeros", "random"])
|
||||
def testdata(request, tmpdir_factory):
|
||||
count, size = 10, 1000*1000
|
||||
assert size <= len(zeros)
|
||||
p = tmpdir_factory.mktemp('data')
|
||||
data_type = request.param
|
||||
if data_type == 'zeros':
|
||||
# do not use a binary zero (\0) to avoid sparse detection
|
||||
def data(size):
|
||||
return b'0' * size
|
||||
return memoryview(zeros)[:size]
|
||||
elif data_type == 'random':
|
||||
def data(size):
|
||||
return os.urandom(size)
|
||||
|
|
Loading…
Reference in a new issue