mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
fix(benchmark): add rate-limit refill cooldown for send_10_receive_10 and avoid fixture signature mismatch
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
def test_tls_imap(benchmark, imap):
|
def test_tls_imap(benchmark, imap):
|
||||||
def imap_connect():
|
def imap_connect():
|
||||||
imap.connect()
|
imap.connect()
|
||||||
@@ -47,7 +48,7 @@ class TestDC:
|
|||||||
|
|
||||||
benchmark(dc_ping_pong, 5)
|
benchmark(dc_ping_pong, 5)
|
||||||
|
|
||||||
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
def test_send_10_receive_10(self, request, cmfactory, chatmail_config, lp):
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
@@ -57,4 +58,16 @@ class TestDC:
|
|||||||
for i in range(10):
|
for i in range(10):
|
||||||
ac2._evtracker.wait_next_incoming_message()
|
ac2._evtracker.wait_next_incoming_message()
|
||||||
|
|
||||||
benchmark(dc_send_10_receive_10, 5)
|
per_minute = max(chatmail_config.max_user_send_per_minute, 1)
|
||||||
|
cooldown = chatmail_config.max_user_send_burst_size * 60 / per_minute
|
||||||
|
durations = []
|
||||||
|
num = 5
|
||||||
|
for i in range(num):
|
||||||
|
now = time.time()
|
||||||
|
dc_send_10_receive_10()
|
||||||
|
durations.append(time.time() - now)
|
||||||
|
if i + 1 < num:
|
||||||
|
# Keep post-run cooldown out of measured benchmark duration.
|
||||||
|
time.sleep(cooldown)
|
||||||
|
durations.sort()
|
||||||
|
request.config._benchresults["dc_send_10_receive_10"] = (None, durations)
|
||||||
|
|||||||
Reference in New Issue
Block a user