Skip to content

FrameStatsOptions

Defined in: src/modules/stats/frame-stats.ts:16

Headless frame-timing collector: feed it the measured duration of each frame (or logic tick) and read back current/min/max/avg frame time and FPS, gamer-standard 1% / 0.1% lows, a recent-history ring for sparklines, and arbitrary named counters.

Pure and DOM-free so it works for any loop (render rAF, fixed logic tick, a worker). Rendering a panel is a consumer concern — see drawStatsOverlay for an optional Canvas2D drawer, or read the getters and draw your own.

sample is allocation-free on the hot path (a frame-stats tool must not itself create GC pressure): samples live in preallocated ring buffers and percentiles sort a reused scratch array in place.

optional historySize?: number

Defined in: src/modules/stats/frame-stats.ts:23

Number of recent frame durations retained for FrameStats.history (the sparkline). Also caps the rolling-window ring, so a window holding more frames than this silently drops the oldest from the stats too — size it for your worst-case frame rate (default 120 ≈ 2s at 60fps).


optional windowMs?: number

Defined in: src/modules/stats/frame-stats.ts:29

Rolling window (ms) over which min/max/avg and the percentile lows are computed, so the HUD reflects recent behaviour rather than all-time. Default 1000.