mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
slight refinement for benchmark formatting, not worth a PR
This commit is contained in:
@@ -45,7 +45,7 @@ class TestDC:
|
||||
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)
|
||||
@@ -57,4 +57,4 @@ class TestDC:
|
||||
for i in range(10):
|
||||
ac2.wait_next_incoming_message()
|
||||
|
||||
benchmark(send_10_receive_10, 1)
|
||||
benchmark(send_10_receive_10, 5)
|
||||
|
||||
@@ -6,6 +6,7 @@ import subprocess
|
||||
import imaplib
|
||||
import smtplib
|
||||
import itertools
|
||||
from math import ceil
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -79,13 +80,24 @@ def pytest_terminal_summary(terminalreporter):
|
||||
tr = terminalreporter
|
||||
results = tr.config._benchresults
|
||||
tr.section("benchmark results")
|
||||
headers = f"{'benchmark name': <30} {'median': >6}"
|
||||
float_names = 'median min max'.split()
|
||||
width = max(map(len, float_names))
|
||||
|
||||
def fcol(parts):
|
||||
return " ".join(part.rjust(width) for part in parts)
|
||||
|
||||
headers = f"{'benchmark name': <30} " + fcol(float_names)
|
||||
tr.write_line(headers)
|
||||
tr.write_line("-" * len(headers))
|
||||
for name, durations in results.items():
|
||||
median = sorted(durations)[len(durations) // 2]
|
||||
median = f"{median:2.4f}"
|
||||
tr.write_line(f"{name: <30} {median: >6}")
|
||||
measures = [
|
||||
sorted(durations)[len(durations) // 2],
|
||||
min(durations),
|
||||
max(durations),
|
||||
]
|
||||
line = f"{name: <30} "
|
||||
line += fcol(f"{float: 2.2f}" for float in measures)
|
||||
tr.write_line(line)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user