From 34d200dd2ea56745e6fdad24c867e6b4af62e179 Mon Sep 17 00:00:00 2001 From: onmax Date: Sat, 7 Nov 2026 11:35:08 +0100 Subject: [PATCH] test(tinyaml): confirm a slope over 1.8 at 4x on 16x before failing A linear reader came out at 1.87 at 4 times the input on CI (Node 22, reading empty documents with tinyaml/js-yaml), and the early exit failed it there. Now a slope over 1.8 at 4x reads 16x once more and that slope decides, so a quadratic reader still fails soon. --- packages/tinyaml/test/fixtures.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/tinyaml/test/fixtures.ts b/packages/tinyaml/test/fixtures.ts index e7e06f2..2851deb 100644 --- a/packages/tinyaml/test/fixtures.ts +++ b/packages/tinyaml/test/fixtures.ts @@ -30,8 +30,10 @@ export const LINEAR = 1.5; // quadratic; tests check it stays under LINEAR. It reads the n that makes // about `chars` characters, and 16 times as many, enough for quadratic work // to show over the linear, each up to ten times, while they take less than -// 100 ms in all, and keeps the fastest. On the way it reads 4 times as many, and stops -// there when the slope is already over 1.8, so a quadratic reader fails soon. +// 100 ms in all, and keeps the fastest. On the way it reads 4 times as many, +// and when the slope there is already over 1.8 it reads 16 times as many just +// once more, so a quadratic reader fails soon; a linear one on CI once came +// out at 1.87 there. // A slope over its limit is measured up to twice more, with the fastest runs // of all rounds, since a busy machine may hold up the compiler or share a // core's caches for one. It counts CPU time, which a busy machine stretches @@ -65,8 +67,8 @@ export function slope( const limit = Error.stackTraceLimit; Error.stackTraceLimit = 0; try { - const middle = growth(4, 1.8); - return middle > 1.8 ? middle : growth(16, LINEAR); + if (growth(4, 1.8) > 1.8) return Math.log(best(16) / best(1)) / Math.log(16); + return growth(16, LINEAR); } finally { Error.stackTraceLimit = limit; }