Skip to content

Commit 7a28e9b

Browse files
committed
fix: scale style-unitless bench checksum by sample size
Warmup accumulated 200 lookup CSS lengths while timed samples used 1_000_000, so the equality check always failed before ratios ran.
1 parent 0ac824c commit 7a28e9b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎benchmarks/style-unitless/run.mjs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { summarizeSamples, timingStatForJson } from '../lib/stats.mjs';
55

66
const iterations = Number.parseInt(process.argv[2] ?? '8', 10);
77
const LOOKUPS_PER_SAMPLE = 1_000_000;
8+
const WARMUP_LOOKUPS = 200;
89

910
if (!Number.isSafeInteger(iterations) || iterations < 1) {
1011
throw new Error('style-unitless iterations must be a positive integer');
@@ -144,10 +145,10 @@ assert.equal(cssStyleValue('--gap', 8), '8', 'custom property gained px');
144145

145146
const expectedChecksums = new Map();
146147
for (const scenario of scenarios) {
147-
const warmup = runLookups(scenario.serialize, scenario.names, scenario.nums, 200);
148-
const control = runLookups(cssStyleValueScan, scenario.names, scenario.nums, 200);
148+
const warmup = runLookups(scenario.serialize, scenario.names, scenario.nums, WARMUP_LOOKUPS);
149+
const control = runLookups(cssStyleValueScan, scenario.names, scenario.nums, WARMUP_LOOKUPS);
149150
assert.equal(warmup.checksum, control.checksum, scenario.name + ' warmup drifted');
150-
expectedChecksums.set(scenario.name, warmup.checksum);
151+
expectedChecksums.set(scenario.name, warmup.checksum * (LOOKUPS_PER_SAMPLE / WARMUP_LOOKUPS));
151152
}
152153

153154
const samples = new Map();

0 commit comments

Comments
 (0)