From 99ba8a5f0f55a5f63e983278bfaa85cf67b2d3d8 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 9 Nov 2022 18:25:37 +0100 Subject: [PATCH] Visually align results a bit more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always make the test number at least two digits wide, but remove the space before it. For numbers below 10, this makes no difference; for numbers between 10 and 99, it makes the number aligned with the lower numbers; only at 100 and above will the numbers start to become unaligned. Always make the test duration at least six characters wide in total. The decimal digits stay at 3 as before; subtracting one character for the decimal point itself, that leaves a minimum of two for the “seconds” part, so that test durations up to 99 seconds now stay aligned with each other, and only become unaligned at ≥ 100 seconds. --- src/SpeedTrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SpeedTrap.php b/src/SpeedTrap.php index 9b84d2c..8ca78bc 100644 --- a/src/SpeedTrap.php +++ b/src/SpeedTrap.php @@ -211,7 +211,7 @@ protected function renderBody(): void $time = array_shift($slowTests); $seconds = $time / 1000; - echo sprintf(" %s) %.3fs to run %s\n", $i, $seconds, $label); + echo sprintf("%2s) %6.3fs to run %s\n", $i, $seconds, $label); } }