From ca418489660335309600f5f633800240073ee98e Mon Sep 17 00:00:00 2001 From: Jeff Repanich Date: Sun, 2 Aug 2026 10:33:44 -0400 Subject: [PATCH] fix(bench): stabilize peer solver timing --- CHANGELOG.md | 1 + benchmarks/cli.mjs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d593f2..65b28d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update `vite-plus` to 0.2.6 after passing the complete cross-platform, template, packaging, and performance gates. - Update `npm-registry-fetch` to 20.0.1 and `@npmcli/config` to 11.0.1 after isolated major-version verification. +- Measure the peer-solver benchmark as batched per-operation wall-clock time so isolated hosted-runner scheduling or garbage-collection pauses cannot create false regressions. ## [0.0.19] - 2026-08-02 diff --git a/benchmarks/cli.mjs b/benchmarks/cli.mjs index 8798c52..2350be5 100644 --- a/benchmarks/cli.mjs +++ b/benchmarks/cli.mjs @@ -58,13 +58,19 @@ function solverSample() { const packuments = new Map( occurrences.map(({ package: name }) => [name, { "dist-tags": { latest: "1.7.0" }, versions }]), ); + const solvesPerSample = 5; const samples = []; for (let index = 0; index < 12; index += 1) { + // Average a small batch so a single hosted-runner scheduling or GC pause + // cannot masquerade as a solver regression. The reported value remains + // wall-clock milliseconds per 100-package solve with the same 50 ms budget. const started = performance.now(); - const result = planUpdates({ occurrences, packuments, mode: "upgrade" }); - if (result.summary.packages !== 100) - throw new Error("synthetic peer solver returned an incomplete plan"); - if (index >= 2) samples.push(performance.now() - started); + for (let solve = 0; solve < solvesPerSample; solve += 1) { + const result = planUpdates({ occurrences, packuments, mode: "upgrade" }); + if (result.summary.packages !== 100) + throw new Error("synthetic peer solver returned an incomplete plan"); + } + if (index >= 2) samples.push((performance.now() - started) / solvesPerSample); } return samples; }