From 83e6a4225267b25eb601d2adec9b104279f6064f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 20 Oct 2023 18:43:06 +0200 Subject: [PATCH] slight refinement for benchmark formatting, not worth a PR --- online-tests/benchmark.py | 4 ++-- online-tests/conftest.py | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/online-tests/benchmark.py b/online-tests/benchmark.py index ece8bda7..13aac3e0 100644 --- a/online-tests/benchmark.py +++ b/online-tests/benchmark.py @@ -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) diff --git a/online-tests/conftest.py b/online-tests/conftest.py index 1bc6636c..3c3cfc95 100644 --- a/online-tests/conftest.py +++ b/online-tests/conftest.py @@ -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