mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
add ping-pong bench and formatting
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user