feat: more precise stats

This commit is contained in:
2025-11-10 16:01:25 +01:00
parent 05f7980a7b
commit ff06dfd75f

View File

@@ -4,7 +4,7 @@ const props = withDefaults(defineProps<{ x?: number; y?: number }>(), {
y: 0, y: 0,
}); });
const SAMPLES = 60; const SAMPLES = 600;
let average = { deltaTime: 0, realDeltaTime: 0 }; let average = { deltaTime: 0, realDeltaTime: 0 };
const lastFrames: (typeof average)[] = []; const lastFrames: (typeof average)[] = [];
@@ -36,7 +36,7 @@ useRender((ctx) => {
let textY = props.y; let textY = props.y;
ctx.fillStyle = "black"; ctx.fillStyle = "black";
ctx.fillText("[avg on 60 frames]", props.x, (textY += LINE_HEIGHT)); ctx.fillText(`[avg on ${SAMPLES} frames]`, props.x, (textY += LINE_HEIGHT));
ctx.fillText( ctx.fillText(
`fps=${(1000 / average.deltaTime).toFixed()}`, `fps=${(1000 / average.deltaTime).toFixed()}`,
props.x, props.x,