Skip to content

FrameStats

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

Headless frame-timing collector (see the description on FrameStatsOptions): sample each frame’s duration, then read back current/min/max/avg frame time and FPS, the 1%/0.1% lows, a recent-history ring for sparklines, and named counters. Allocation-free on the hot path.

new FrameStats(options?): FrameStats

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

FrameStatsOptions = {}

FrameStats

get avgFps(): number

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

number


get avgMs(): number

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

number


get counters(): ReadonlyMap<string, number>

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

ReadonlyMap<string, number>


get fps(): number

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

number


get history(): number[]

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

Recent frame durations (ms) oldest→newest, for a sparkline. A fresh array is built per call (small, bounded by historySize); call it once per draw, not in the hot loop.

number[]


get low01Fps(): number

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

0.1% low FPS: the 99.9th-percentile frame time expressed as FPS.

number


get low1Fps(): number

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

1% low FPS: the 99th-percentile frame time expressed as FPS.

number


get maxFps(): number

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

Highest FPS in the window — derived from the best frame time.

number


get maxMs(): number

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

Worst (longest) frame in the window — the visible hitch.

number


get minFps(): number

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

Lowest FPS in the window — derived from the worst frame time.

number


get minMs(): number

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

Best (shortest) frame in the window.

number


get ms(): number

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

Most recent frame duration (ms), or 0 before the first sample.

number

reset(): void

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

Clear all samples, counters, and the internal clock.

void


sample(deltaMs): void

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

Record one frame’s measured duration (ms). Advances an internal clock by deltaMs and evicts samples older than windowMs. Non-positive or non-finite deltas are ignored (the first rAF frame reports 0, and a paused tab can yield spikes/NaN — neither should pollute the stats).

number

void


setCounter(label, value): void

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

Set/overwrite a named counter (e.g. live entity counts) for display.

string

number

void