perf: reduce mobile rendering and cull offscreen characters and building tiles
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createFrameClock } from '../src/scene/frameClock.ts';
|
||||
|
||||
test('30 fps pacing retains elapsed simulation time on 60 and 120 Hz displays', () => {
|
||||
for (const hz of [60, 120]) {
|
||||
const clock = createFrameClock(30);
|
||||
let frames = 0, elapsed = 0;
|
||||
for (let i = 0; i <= hz * 10; i++) {
|
||||
const delta = clock.tick(i * 1000 / hz);
|
||||
if (delta !== undefined) { frames++; elapsed += delta; }
|
||||
}
|
||||
assert.equal(frames, 301);
|
||||
assert.ok(Math.abs(elapsed - 10) < 1e-8);
|
||||
}
|
||||
});
|
||||
|
||||
test('resume resets elapsed time instead of simulating the hidden interval', () => {
|
||||
const clock = createFrameClock(30);
|
||||
clock.tick(0); clock.tick(100);
|
||||
clock.reset();
|
||||
assert.equal(clock.tick(60000), 0);
|
||||
assert.equal(clock.tick(60001), undefined);
|
||||
});
|
||||
Reference in New Issue
Block a user