Puzzle speed test: time the fastest of 7 evaluations, so a busy CI runner cannot fail it

This commit is contained in:
Frederic Jung 2026-11-01 18:09:52 +01:00
parent 167e2a715b
commit de9b56befe
No known key found for this signature in database

View file

@ -264,7 +264,8 @@ test('determinism and speed: the same build always gets the same stars, fast eno
const big = ev("PZ.map(p=>p.id).sort()[0]") && JSON.parse(ev('JSON.stringify(PZ.map(p=>p.id))')).map((id) => { ev(`pzBegin(pzDef('${id}'))`); build(ev, REF[id].three); return [id, ev('new Set(S.links.map(pzUnit)).size')]; }).sort((x, y) => y[1] - x[1])[0];
ev(`pzBegin(pzDef('${big[0]}'))`); build(ev, REF[big[0]].three);
for (let i = 0; i < 3; i++) ev('UI.pzEv=null;pzEval()');
const ms = ev('(()=>{const t=performance.now();for(let i=0;i<5;i++){UI.pzEv=null;pzEval();}return (performance.now()-t)/5})()');
// The fastest of 7 runs: a busy machine (shared CI runners) slows some runs, never all of them.
const ms = ev('(()=>{let b=Infinity;for(let i=0;i<7;i++){const t=performance.now();UI.pzEv=null;pzEval();b=Math.min(b,performance.now()-t);}return b})()');
console.log(`# star evaluation on ${big[0]} (${big[1]} failure units): ${ms.toFixed(1)} ms`);
assert.ok(ms < 150, `${big[0]}: ${ms.toFixed(1)} ms`);
assert.deepEqual(errors, []);