Timer

interface Timer
packages/shared/src/timing.ts:113

Members

onreadonly

on: boolean

Cheap enough to read in a per-frame branch. False until a sink attaches.

A getter over the live hub, never a captured boolean. A module-scope const timer = getTimer('game.engine') is constructed while the hub still has no sink — ES modules evaluate every static import to completion before the importing module's first statement runs, and the entry point attaches the sink in its own body. A snapshot taken at that moment is false for the life of the process, the instrumentation records nothing, and nothing fails. A getter that reads one boolean off the hub costs the same at the call site — a property read on a monomorphic object, no allocation — and cannot go stale.

child

child(scope: string) → Timer
scopestring
Undocumented

mark

mark(name: string, detail?: TimingDetail) → void

An instant. detail is only built when on.

namestring
Undocumented
detailTimingDetail
Undocumented

measure

measure(name: string, startMs: number, endMs: number, detail?: TimingDetail) → void

A closed interval from numbers the caller already has.

namestring
Undocumented
startMsnumber
Undocumented
endMsnumber
Undocumented
detailTimingDetail
Undocumented

span

span(name: string, detail?: TimingDetail) → Span

An open interval, closed by end().

namestring
Undocumented
detailTimingDetail
Undocumented