add ping-pong bench and formatting

This commit is contained in:
holger krekel
2023-10-20 10:28:16 +02:00
parent 1b347f97a0
commit 1ae6291d06
2 changed files with 17 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ def test_tls_smtp(benchmark, smtp):
benchmark(smtp_connect, 10)
def test_login_smtp(benchmark, smtp, gencreds):
def smtp_connect_and_login():
smtp.connect()
@@ -39,3 +40,17 @@ def test_send_and_receive_10(benchmark, cmfactory, lp):
ac2.wait_next_incoming_message()
benchmark(send_10_receive_all, 1)
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()
benchmark(ping_pong, 5)

View File

@@ -68,9 +68,10 @@ def benchmark(request):
for i in range(num):
now = time.time()
func()
durations.append(time.time()-now)
durations.append(time.time() - now)
durations.sort()
request.config._benchresults[name] = durations
return bench
@@ -84,7 +85,6 @@ def pytest_terminal_summary(terminalreporter):
tr.write_line(f"{name: <30} {median:2.4f} seconds")
@pytest.fixture
def imap(maildomain):
return ImapConn(maildomain)