From 03442bc115e0bb8658fbd2872902642ed2af3b6a Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 20 Oct 2023 10:59:26 +0200 Subject: [PATCH] some improvements, adding a bnech --- online-tests/benchmark.py | 45 ++++++++++++++++++++++----------------- online-tests/conftest.py | 6 +++++- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/online-tests/benchmark.py b/online-tests/benchmark.py index 4a7bb551..15ae8063 100644 --- a/online-tests/benchmark.py +++ b/online-tests/benchmark.py @@ -28,29 +28,34 @@ def test_login_smtp(benchmark, smtp, gencreds): benchmark(smtp_connect_and_login, 10) -def test_send_and_receive_10(benchmark, cmfactory, lp): - """send many messages between two accounts""" - ac1, ac2 = cmfactory.get_online_accounts(2) - chat = cmfactory.get_accepted_chat(ac1, ac2) +class TestDC: + def test_autoconfigure(self, benchmark, cmfactory): - def send_10_receive_all(): - for i in range(10): - chat.send_text(f"hello {i}") - for i in range(10): - ac2.wait_next_incoming_message() + def autoconfig_and_idle_ready(): + cmfactory.get_online_accounts(1) - 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): - """send many messages between two accounts""" - ac1, ac2 = cmfactory.get_online_accounts(2) - chat = cmfactory.get_accepted_chat(ac1, ac2) + def ping_pong(): + chat.send_text("ping") + msg = ac2.wait_next_incoming_message() + msg.chat.send_text("pong") + ac1.wait_next_incoming_message() - def ping_pong(): - chat.send_text("ping") - msg = ac2.wait_next_incoming_message() - msg.chat.send_text("pong") - ac1.wait_next_incoming_message() + benchmark(ping_pong, 3) - 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) diff --git a/online-tests/conftest.py b/online-tests/conftest.py index a4696698..9809c824 100644 --- a/online-tests/conftest.py +++ b/online-tests/conftest.py @@ -79,10 +79,14 @@ def pytest_terminal_summary(terminalreporter): tr = terminalreporter results = tr.config._benchresults 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(): overall = sum(durations) 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