Skip to content

Commit aada045

Browse files
committed
fix: guard timeMedianWithValue against runs=0 (#2016)
docs check acknowledged — defensive guard only, not reachable at current call sites. Impact: 1 functions changed, 2 affected
1 parent 86e006b commit aada045

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

scripts/lib/bench-timing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export async function timeMedianWithValue<T>(
8181
const value = await fn(i);
8282
samples.push({ ms: performance.now() - start, value });
8383
}
84+
if (samples.length === 0) {
85+
throw new Error('timeMedianWithValue: runs must be >= 1');
86+
}
8487
samples.sort((a, b) => a.ms - b.ms);
8588
return samples[Math.floor(samples.length / 2)];
8689
}

0 commit comments

Comments
 (0)