From 93504b7cc4f6cb4c3dec0f9c0e35763ef2fbe15d Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 14 Oct 2026 10:45:01 +0200 Subject: [PATCH] Show elapsed time in seconds for runs longer than 5s --- blink/internal/reporter/reporter.go | 10 +++++++++- src/Console/Command/CheckCommand.php | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/blink/internal/reporter/reporter.go b/blink/internal/reporter/reporter.go index b2b3b37a29..00c093b71a 100644 --- a/blink/internal/reporter/reporter.go +++ b/blink/internal/reporter/reporter.go @@ -58,7 +58,15 @@ func Report(w io.Writer, results []runner.FileResult, isFixer bool) int { // Footer prints an ECS-style run summary: files scanned, time and memory. func Footer(w io.Writer, files int, d time.Duration, memBytes uint64) { - _, _ = fmt.Fprintf(w, " // %d files · %s · %d MB\n", files, d.Truncate(time.Millisecond), memBytes/(1024*1024)) + _, _ = fmt.Fprintf(w, " // %d files · %s · %d MB\n", files, formatElapsed(d), memBytes/(1024*1024)) +} + +// formatElapsed shows seconds past 5s, milliseconds below. +func formatElapsed(d time.Duration) string { + if d > 5*time.Second { + return fmt.Sprintf("%.2f s", d.Seconds()) + } + return fmt.Sprintf("%dms", d.Truncate(time.Millisecond).Milliseconds()) } func newFormatter(w io.Writer) formatter { diff --git a/src/Console/Command/CheckCommand.php b/src/Console/Command/CheckCommand.php index f068f78538..3b04d9a712 100644 --- a/src/Console/Command/CheckCommand.php +++ b/src/Console/Command/CheckCommand.php @@ -125,8 +125,12 @@ private function printRunFooter(int $filesCount, float $startTime): void $elapsedMilliseconds = (int) round((microtime(true) - $startTime) * 1000); $peakMemoryMegabytes = (int) round(memory_get_peak_usage(true) / 1024 / 1024); + $elapsedTime = $elapsedMilliseconds > 5000 + ? sprintf('%.2f s', $elapsedMilliseconds / 1000) + : sprintf('%dms', $elapsedMilliseconds); + $this->easyCodingStandardStyle->writeln( - sprintf(' // %d files · %dms · %d MB', $filesCount, $elapsedMilliseconds, $peakMemoryMegabytes) + sprintf(' // %d files · %s · %d MB', $filesCount, $elapsedTime, $peakMemoryMegabytes) ); } }