A slow phone gives a day longer slices between frames

A device that cannot hold 50 frames a second waited a whole slow frame at almost every rest of a big day, so the
game played up to a third slower at 8x. There a day gets half of its own frame, up to 32 ms; screens that keep up
keep 3 to 8 ms.
This commit is contained in:
Frederic Jung 2026-11-06 22:48:52 +01:00
parent 410eb81544
commit 52e740cdae
No known key found for this signature in database
4 changed files with 20 additions and 3 deletions

View file

@ -15,4 +15,17 @@ test("a day's steps follow the screen: half a frame between two, from 3 to 8 ms"
assert.deepEqual(errors, []);
});
// A slow phone draws 20 frames a second: at 8 ms a slice, a big day there waited a 50 ms frame at almost every step and
// played a third slower than before the day was split. It gets half of its own frame, never more than 32 ms.
test("a device that cannot hold 50 frames a second gives a day half its frame, 32 ms at most", () => {
const { ev, errors } = load();
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip();closeModal();UI.speed=0;");
const run = (hz, n) => ev(`(()=>{for(let i=0;i<${n};i++){window.__now=(window.__now||1000)+1000/${hz};frame(__now);}return RW.budget;})()`);
assert.equal(run(60, 300), 8, 'a 60 Hz screen keeps 8 ms');
assert.ok(Math.abs(run(20, 300) - 25) < 0.5, `20 frames a second: half of 50 ms, ${ev('RW.budget')}`);
assert.equal(run(8, 300), 32, 'never more than 32 ms');
assert.equal(run(240, 400), 3, 'and back to 3 ms on a fast screen');
assert.deepEqual(errors, []);
});
// The diverse-paths map new offers ask about (60-requirements.js) is built a millisecond a frame, before the first one