mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-06 01:21:43 +00:00
Add a little timing.
This commit is contained in:
parent
16d14c8688
commit
a3e02f14c9
@ -8,6 +8,9 @@ TODO Parameterization (pytest?)
|
|||||||
- Number of needed/happy/total shares.
|
- Number of needed/happy/total shares.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from time import time
|
||||||
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from twisted.trial.unittest import TestCase
|
from twisted.trial.unittest import TestCase
|
||||||
|
|
||||||
from allmydata.util.deferredutil import async_to_deferred
|
from allmydata.util.deferredutil import async_to_deferred
|
||||||
@ -16,16 +19,25 @@ from allmydata.test.common_system import SystemTestMixin
|
|||||||
from allmydata.immutable.upload import Data as UData
|
from allmydata.immutable.upload import Data as UData
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def timeit(name):
|
||||||
|
start = time()
|
||||||
|
try:
|
||||||
|
yield
|
||||||
|
finally:
|
||||||
|
print(f"{name}: {time() - start:.3f}")
|
||||||
|
|
||||||
|
|
||||||
class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
||||||
"""Benchmarks for immutables."""
|
"""Benchmarks for immutables."""
|
||||||
|
|
||||||
FORCE_FOOLSCAP_FOR_STORAGE = True
|
FORCE_FOOLSCAP_FOR_STORAGE = False
|
||||||
|
|
||||||
@async_to_deferred
|
@async_to_deferred
|
||||||
async def test_upload_and_download(self):
|
async def test_upload_and_download(self):
|
||||||
self.basedir = self.mktemp()
|
self.basedir = self.mktemp()
|
||||||
|
|
||||||
DATA = b"Some data to upload\n" * 2000
|
DATA = b"Some data to upload\n" * 10
|
||||||
|
|
||||||
# 3 nodes
|
# 3 nodes
|
||||||
await self.set_up_nodes(3)
|
await self.set_up_nodes(3)
|
||||||
@ -36,11 +48,14 @@ class ImmutableBenchmarks(SystemTestMixin, TestCase):
|
|||||||
c.encoding_params["happy"] = 3
|
c.encoding_params["happy"] = 3
|
||||||
c.encoding_params["n"] = 3
|
c.encoding_params["n"] = 3
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
# 1. Upload:
|
# 1. Upload:
|
||||||
|
with timeit("upload"):
|
||||||
uploader = self.clients[0].getServiceNamed("uploader")
|
uploader = self.clients[0].getServiceNamed("uploader")
|
||||||
results = await uploader.upload(UData(DATA, convergence=None))
|
results = await uploader.upload(UData(DATA, convergence=None))
|
||||||
|
|
||||||
# 2. Download:
|
# 2. Download:
|
||||||
|
with timeit("download"):
|
||||||
uri = results.get_uri()
|
uri = results.get_uri()
|
||||||
node = self.clients[1].create_node_from_uri(uri)
|
node = self.clients[1].create_node_from_uri(uri)
|
||||||
mc = await node.read(MemoryConsumer(), 0, None)
|
mc = await node.read(MemoryConsumer(), 0, None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user