Skip to content

1681-engine / index / FrameSampler

Class: FrameSampler ​

Defined in: src/diagnostics/FrameSampler.ts:24

Measures how a game really runs on a player's device: each frame costs one number pushed on an array, and every windowMs the window is summed into a FrameSummary handed to onSample — FPS, the 1% low, the 95th-percentile frame, hitches. The engine sends nothing anywhere: what the game does with a sample (a readout, a report to its server) is the callback's.

Constructors ​

Constructor ​

ts
new FrameSampler(onSample, options?): FrameSampler;

Defined in: src/diagnostics/FrameSampler.ts:31

Parameters ​

ParameterType
onSample(summary) => void
optionsFrameSamplerOptions

Returns ​

FrameSampler

Methods ​

attach() ​

ts
attach(ticker): () => void;

Defined in: src/diagnostics/FrameSampler.ts:66

Feeds the sampler from a Pixi ticker, after the render; returns the detach.

Parameters ​

ParameterType
tickerTicker

Returns ​

() => void


push() ​

ts
push(deltaMs): void;

Defined in: src/diagnostics/FrameSampler.ts:44

One frame of deltaMs; sums the window once it is full.

Parameters ​

ParameterType
deltaMsnumber

Returns ​

void


reset() ​

ts
reset(): void;

Defined in: src/diagnostics/FrameSampler.ts:60

Starts a fresh window, dropping what was counted (after a scene change, say).

Returns ​

void

Released under the MIT License.