summaryrefslogtreecommitdiff
path: root/testing/tests/perf/test_sync.py
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-08-29 00:05:45 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-08-29 12:26:24 -0300
commitd86831e4cd3e77f340618168528e62cf4dafb5d7 (patch)
treed5491c9ec432729d41c177d9753c80e7598046e2 /testing/tests/perf/test_sync.py
parent49d4013819733966c05178254725e6a89f1909fe (diff)
[test] randomize payload
We were using 'x'*size as payload, but on real usage the payload will be random. This commit randomizes the payload using a predefined seed, so the random payload will be the same across benchmarks. Using random payloads also improves accuracy of compression or encoding impacts and we will be evaluating those changes for resouce usage issues. Also note that base64 is used on payload. That was needed for utf8 safety, but overhead was removed to leave payloads as defined by benchmarks. Base64 was chosen also due its popular usage on MIME encoding, which is used on mail attachments (our current scenario).
Diffstat (limited to 'testing/tests/perf/test_sync.py')
-rw-r--r--testing/tests/perf/test_sync.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/testing/tests/perf/test_sync.py b/testing/tests/perf/test_sync.py
index 0be9d12f..0b48a0b9 100644
--- a/testing/tests/perf/test_sync.py
+++ b/testing/tests/perf/test_sync.py
@@ -3,12 +3,11 @@ import pytest
from twisted.internet.defer import gatherResults
-def load_up(client, amount, size):
- content = 'x'*size
+def load_up(client, amount, payload):
deferreds = []
# create a bunch of local documents
for i in xrange(amount):
- d = client.create_doc({'content': content})
+ d = client.create_doc({'content': payload})
deferreds.append(d)
d = gatherResults(deferreds)
d.addCallback(lambda _: None)
@@ -18,11 +17,11 @@ def load_up(client, amount, size):
def create_upload(uploads, size):
@pytest.inlineCallbacks
@pytest.mark.benchmark(group="test_upload")
- def test(soledad_client, txbenchmark_with_setup):
+ def test(soledad_client, txbenchmark_with_setup, payload):
client = soledad_client()
def setup():
- return load_up(client, uploads, size)
+ return load_up(client, uploads, payload(size))
yield txbenchmark_with_setup(setup, client.sync)
return test
@@ -36,10 +35,10 @@ test_upload_1000_10k = create_upload(1000, 10*1000)
def create_download(downloads, size):
@pytest.inlineCallbacks
@pytest.mark.benchmark(group="test_download")
- def test(soledad_client, txbenchmark_with_setup):
+ def test(soledad_client, txbenchmark_with_setup, payload):
client = soledad_client()
- yield load_up(client, downloads, size)
+ yield load_up(client, downloads, payload(size))
yield client.sync()
# We could create them directly on couch, but sending them
# ensures we are dealing with properly encrypted docs