From f6dda48bb7367acbcd023943fbbe721c01b6aa64 Mon Sep 17 00:00:00 2001 From: Oddur Sigurdsson Date: Fri, 16 Oct 2026 21:42:30 -0400 Subject: [PATCH] test(perf): time the fastest batch so load can't fail the gate The debug ranking gate averaged twenty runs, so one busy moment on a loaded Mac pushed it over budget: main itself measured 37 and 45 ms against 40 while its fastest runs took 11. Load can only slow a batch down, so the fastest of five batches measures the code rather than the machine. The budget is unchanged. --- Tests/CommandKitTests/PerformanceTests.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Tests/CommandKitTests/PerformanceTests.swift b/Tests/CommandKitTests/PerformanceTests.swift index c9b2709..c6f139e 100644 --- a/Tests/CommandKitTests/PerformanceTests.swift +++ b/Tests/CommandKitTests/PerformanceTests.swift @@ -7,11 +7,18 @@ import Testing /// measures, so they catch an accidental quadratic loop without flaking on a busy CI runner. @Suite(.serialized) struct PerformanceTests { + /// The mean of the fastest of five batches. Other work on the machine can only slow a batch down, never + /// speed it up, so the fastest batch is the closest to the code's own cost. An average over everything + /// let one busy moment fail the gate on a loaded Mac. func averageMicroseconds(_ iterations: Int, _ body: () -> Void) -> Double { body() - let start = DispatchTime.now().uptimeNanoseconds - for _ in 0..