mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
some improvements, adding a bnech
This commit is contained in:
@@ -28,29 +28,34 @@ def test_login_smtp(benchmark, smtp, gencreds):
|
|||||||
benchmark(smtp_connect_and_login, 10)
|
benchmark(smtp_connect_and_login, 10)
|
||||||
|
|
||||||
|
|
||||||
def test_send_and_receive_10(benchmark, cmfactory, lp):
|
class TestDC:
|
||||||
"""send many messages between two accounts"""
|
def test_autoconfigure(self, benchmark, cmfactory):
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
|
||||||
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
|
||||||
|
|
||||||
def send_10_receive_all():
|
def autoconfig_and_idle_ready():
|
||||||
for i in range(10):
|
cmfactory.get_online_accounts(1)
|
||||||
chat.send_text(f"hello {i}")
|
|
||||||
for i in range(10):
|
|
||||||
ac2.wait_next_incoming_message()
|
|
||||||
|
|
||||||
benchmark(send_10_receive_all, 1)
|
benchmark(autoconfig_and_idle_ready, 5)
|
||||||
|
|
||||||
|
def test_ping_pong(self, benchmark, cmfactory):
|
||||||
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
def test_ping_pong(benchmark, cmfactory, lp):
|
def ping_pong():
|
||||||
"""send many messages between two accounts"""
|
chat.send_text("ping")
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
msg = ac2.wait_next_incoming_message()
|
||||||
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
msg.chat.send_text("pong")
|
||||||
|
ac1.wait_next_incoming_message()
|
||||||
|
|
||||||
def ping_pong():
|
benchmark(ping_pong, 3)
|
||||||
chat.send_text("ping")
|
|
||||||
msg = ac2.wait_next_incoming_message()
|
|
||||||
msg.chat.send_text("pong")
|
|
||||||
ac1.wait_next_incoming_message()
|
|
||||||
|
|
||||||
benchmark(ping_pong, 5)
|
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
||||||
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
|
def send_10_receive_10():
|
||||||
|
for i in range(10):
|
||||||
|
chat.send_text(f"hello {i}")
|
||||||
|
for i in range(10):
|
||||||
|
ac2.wait_next_incoming_message()
|
||||||
|
|
||||||
|
benchmark(send_10_receive_10, 1)
|
||||||
|
|||||||
@@ -79,10 +79,14 @@ def pytest_terminal_summary(terminalreporter):
|
|||||||
tr = terminalreporter
|
tr = terminalreporter
|
||||||
results = tr.config._benchresults
|
results = tr.config._benchresults
|
||||||
tr.section("benchmark results")
|
tr.section("benchmark results")
|
||||||
|
headers = f"{'benchmark name': <30} {'median': >6}"
|
||||||
|
tr.write_line(headers)
|
||||||
|
tr.write_line("-" * len(headers))
|
||||||
for name, durations in results.items():
|
for name, durations in results.items():
|
||||||
overall = sum(durations)
|
overall = sum(durations)
|
||||||
median = sorted(durations)[len(durations) // 2]
|
median = sorted(durations)[len(durations) // 2]
|
||||||
tr.write_line(f"{name: <30} {median:2.4f} seconds")
|
median = f'{median:2.4f}'
|
||||||
|
tr.write_line(f"{name: <30} {median: >6}")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user