Skip to main content

Stress Test

game.ts
const renderLayers = {
foreground: 1 << 0,
};

export const createStressTestGame = async (): Promise<Game> => {
const { game, world, renderContext, time } = createGame('demo-game');

createCamera(world, {
isStatic: true,
cullingMask: renderLayers.foreground,
verticalWorldUnits: DEMO_VERTICAL_WORLD_UNITS,
});

await createSpriteSpawner(world, renderContext, renderLayers.foreground);

const random = new Random();

world.addSystem(createCameraEcsSystem(time));
world.addSystem(createRenderEcsSystem(renderContext));
world.addSystem(createSpriteSpawnerEcsSystem(time, random));
world.addSystem(createFpsMonitorEcsSystem(time));

return game;
};

This demo spawns batches of sprites at a regular interval, growing the sprite count over time. Open the browser console to see how many sprites had been spawned when the frame rate first dropped below 100, 60 and 30 FPS. Spawning stops once the frame rate drops below 30.