From 088a640b6e4468cecd3e719e1f4edcce87d6c7eb Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 22 Jan 2026 12:15:28 +0000 Subject: [PATCH] tests: Standardise output of connection benchmarks --- docs/changelog.rst | 1 + tests/bench/connection/fork_lifecycle.py | 5 ++++- tests/bench/connection/fork_roundtrip.py | 5 ++++- tests/bench/connection/local_lifecycle.py | 6 ++++-- tests/bench/connection/ssh_roundtrip.py | 6 ++++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 58c34b50..a6908741 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -25,6 +25,7 @@ In progress (unreleased) ``if sys.version_info`` blocks * :gh:issue:`1423` tests: Group and unify naming of connection benchmarks * :gh:issue:`1424` tests: Parameterize connection benchmarks +* :gh:issue:`1424` tests: Standardise output of connection benchmarks v0.3.37 (2026-01-08) diff --git a/tests/bench/connection/fork_lifecycle.py b/tests/bench/connection/fork_lifecycle.py index 7731d53a..cafe835b 100644 --- a/tests/bench/connection/fork_lifecycle.py +++ b/tests/bench/connection/fork_lifecycle.py @@ -26,4 +26,7 @@ def main(router): t = mitogen.core.now() ctx = router.fork(debug=opts.debug) ctx.shutdown(wait=True) - print('++ %d' % 1000 * ((mitogen.core.now() - t0) / (1.0+x))) + + t1 = mitogen.core.now() + mean = (t1 - t0) / opts.iterations + print('++ iterations %d, mean %.03f ms' % (opts.iterations, 1e3 * mean)) diff --git a/tests/bench/connection/fork_roundtrip.py b/tests/bench/connection/fork_roundtrip.py index 7609b923..9ae3abae 100644 --- a/tests/bench/connection/fork_roundtrip.py +++ b/tests/bench/connection/fork_roundtrip.py @@ -32,4 +32,7 @@ def main(router): t0 = mitogen.core.now() for x in xrange(opts.iterations): f.call(do_nothing) - print('++', int(1e6 * ((mitogen.core.now() - t0) / (1.0+x))), 'usec') + + t1 = mitogen.core.now() + mean = (t1 - t0) / opts.iterations + print('++ iterations %d, mean %.03f us' % (opts.iterations, 1e6 * mean)) diff --git a/tests/bench/connection/local_lifecycle.py b/tests/bench/connection/local_lifecycle.py index 6c232202..d48a5ab8 100644 --- a/tests/bench/connection/local_lifecycle.py +++ b/tests/bench/connection/local_lifecycle.py @@ -27,5 +27,7 @@ def main(router): t = mitogen.core.now() f = router.local(debug=opts.debug) tt = mitogen.core.now() - print(x, 1000 * (tt - t)) - print('%.03f ms' % (1000 * (mitogen.core.now() - t0) / (1.0 + x))) + + t1 = mitogen.core.now() + mean = (t1 - t0) / opts.iterations + print('++ iterations %d, mean %.03f ms' % (opts.iterations, 1e3 * mean)) diff --git a/tests/bench/connection/ssh_roundtrip.py b/tests/bench/connection/ssh_roundtrip.py index 7bed604a..9358f946 100644 --- a/tests/bench/connection/ssh_roundtrip.py +++ b/tests/bench/connection/ssh_roundtrip.py @@ -43,6 +43,8 @@ def main(router): while mitogen.core.now() < end: f.call(do_nothing) i += 1 - t1 = mitogen.core.now() - print('++', float(1e3 * (t1 - t0) / (1.0+i)), 'ms') + t1 = mitogen.core.now() + iterations = i + 1 + mean = (t1 - t0) / iterations + print('++ iterations %d, mean %.03f ms' % (iterations, 1e3 * mean))