mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 21:08:03 +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")
|
msg.chat.send_text("pong")
|
||||||
ac1.wait_next_incoming_message()
|
ac1.wait_next_incoming_message()
|
||||||
|
|
||||||
benchmark(ping_pong, 3)
|
benchmark(ping_pong, 5)
|
||||||
|
|
||||||
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
@@ -57,4 +57,4 @@ class TestDC:
|
|||||||
for i in range(10):
|
for i in range(10):
|
||||||
ac2.wait_next_incoming_message()
|
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 imaplib
|
||||||
import smtplib
|
import smtplib
|
||||||
import itertools
|
import itertools
|
||||||
|
from math import ceil
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@@ -79,13 +80,24 @@ def pytest_terminal_summary(terminalreporter):
|
|||||||
tr = terminalreporter
|
tr = terminalreporter
|
||||||
results = tr.config._benchresults
|
results = tr.config._benchresults
|
||||||
tr.section("benchmark results")
|
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(headers)
|
||||||
tr.write_line("-" * len(headers))
|
tr.write_line("-" * len(headers))
|
||||||
for name, durations in results.items():
|
for name, durations in results.items():
|
||||||
median = sorted(durations)[len(durations) // 2]
|
measures = [
|
||||||
median = f"{median:2.4f}"
|
sorted(durations)[len(durations) // 2],
|
||||||
tr.write_line(f"{name: <30} {median: >6}")
|
min(durations),
|
||||||
|
max(durations),
|
||||||
|
]
|
||||||
|
line = f"{name: <30} "
|
||||||
|
line += fcol(f"{float: 2.2f}" for float in measures)
|
||||||
|
tr.write_line(line)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
Reference in New Issue
Block a user