PerfProbe class
Per-frame timing accumulator for the overlay perf harness. Gated by STELLAR_PERFHUD=1 OR a PERFHUD line in game_mini/stellar_perf.flags (mirrors StellarDiagnostics’s flags-file gate via Flag, so Task 4’s measured session can be armed by the deploy-script flags file without a Heroic env edit): when disabled every method early-returns on a single cached field read so production pays nothing.
Frame model.OnGUI fires multiple times per rendered Unity frame (Layout, Repaint, input events). BeginDraw/ EndDraw and BeginWindow/EndWindowaccumulate into the current frame’s running totals across every pass; RecordFrame is called exactly once per Unity frame (from the Host OnGUI sink’s once-per-frame block) to (a) store the frame time, (b) commit the accumulated totals to the published Snapshot, (c) reset the per-frame accumulators, and (d) bump FrameCounter.
Static mutable state is the sanctioned exception here — this is diagnostic infrastructure in the same category as StellarDiagnostics, not business state.
public static class PerfProbePublic Members
Section titled “Public Members”| name | description |
|---|---|
| static FrameCounter { get; } | Monotonic Unity-frame counter; bumped by RecordFrame. |
| static IsEnabled { get; } | true when STELLAR_PERFHUD=1 was set in the environment, or a PERFHUD line is present in stellar_perf.flags, at startup. |
| static LogSink | Optional log sink set by the host at boot; when non-null a per-interval summary line is written to the BepInEx log. |
| static BeginDraw() | Mark the start of the OnGUI draw pass for the current frame. |
| static BeginSeg(…) | Start timing a named segment within the Update path (identifies per-plugin cost). |
| static BeginUpdate() | Mark the start of the managed Update work for the current frame (plugins + services). |
| static BeginWindow(…) | Start timing an individual window’s draw cost for the current frame. |
| static EndDraw() | Mark the end of the OnGUI draw pass for the current frame; accumulated into the frame total. |
| static EndSeg(…) | Stop timing the named segment; accumulates into per-frame totals reported in the log summary. |
| static EndUpdate() | Mark the end of the managed Update work; accumulated ms and managed alloc bytes into the frame total. |
| static EndWindow(…) | Stop timing the named window’s draw cost; accumulated into per-frame per-window totals. |
| static HookBegin() | Returns a start timestamp (ticks) for a hook, or 0 when disabled. |
| static HookBeginAlloc() | Per-thread allocated-bytes baseline for a hook (call on the hook’s thread). |
| static HookEndCombat(…) | Accumulate one combat-hook invocation’s wall-time + this-thread allocation. |
| static HookEndRewired(…) | Accumulate one Rewired keyboard-prefix invocation’s wall-time (diagnostic counter for the render-frame-rate key-block hook; no allocation sampling so the counter stays near-free). |
| static HookEndWire(…) | Accumulate one wire-tap (TCP/UDP recv) invocation’s time + this-thread allocation. |
| static MarkDrawFrame() | Marks that the global-rate draw band ran this tick. Per-window/draw timings only refresh on these frames; on the faster master ticks between draws the last published values are held (otherwise they’d be wiped to empty and the overlay would freeze). No-op unless the harness is enabled. |
| static RecordFrame(…) | Commit the frame being built and start a fresh one. |
| static Snapshot() | Immutable view of the last committed frame for the overlay. |
See Also
Section titled “See Also”- namespace Stellar.Abstractions.Diagnostics