GitNexus/gitnexus/test
Gergő Magyar 4848dce9ea
test(u8): de-flake regex linearity assertions (#1475)
* test(u8): de-flake regex linearity assertions

The single-trial 2x input + 3x ratio bound was razor-thin: a real macOS
CI run failed at ratio 3.01x with small=7.41ms / large=22.31ms - both
above the 5ms noise floor but close enough that single-shot scheduler
jitter pushed the ratio over.

Replace the methodology with four stacked techniques:
  1. Warmup runs before timing (let the JIT tier up)
  2. Median of 5 trials per measurement (eliminates GC + jitter)
  3. 4x input ratio (was 2x) - linear gives ~4x, O(n^2) gives ~16x
  4. 8x ratio bound with a 20ms noise floor on the LARGE measurement

Headroom: linear is expected at ~4x, bound is 8x = 2x safety margin.
A real O(n^2) regression on a 4x input would clock 16x, well outside.
Catastrophic backtracking is still caught by the absolute <500ms cap.

Verified: 10 consecutive local runs all passed.

* test(u8): address PR #1475 review — tighten floor + rename for accuracy

Two follow-ups from Claude's review:

1. Floor semantics: revert to 'skip when BOTH measurements below floor'
   (AND, not single-check) and lower threshold from 20ms back to 5ms.
   Median-of-5 makes 5ms reliably resolvable above performance.now()'s
   ~10-100us band, so the higher floor was unnecessary defense.
   Closes the gap where an O(n^2) regression on a fast runner could
   stay under 500ms AND below 20ms-large to escape both detectors.

2. Rename assertSubLinearRatio -> assertNearLinearScaling. The bound
   is SIZE_RATIO * 2 = 8x on a 4x input = sub-quadratic with 2x
   headroom over linear, not strict sub-linearity. New name reflects
   the actual semantics.
2026-05-10 09:31:47 +01:00
..
fixtures fix(csharp): include generic typed properties in context and impact (#1399) 2026-05-09 09:07:24 +01:00
helpers fix(lbug): robust Windows lock acquisition for CI integration tests (#1430) 2026-05-08 11:58:01 +01:00
integration feat: add IncludeExtractor for C++ cross-repo include tracking (group) (#1156) 2026-05-09 09:31:59 +01:00
unit test(u8): de-flake regex linearity assertions (#1475) 2026-05-10 09:31:47 +01:00
utils ci: add macOS to cross-platform test matrix (#208) 2026-03-07 10:38:32 +00:00