FrameProfiler Type
Collects frame measurements for the running game and serves screenshot requests.
Build one, pass it to the program with withProfiler, and the host
registers it in the GameContext and measures
every frame. When no profiler is supplied, nothing runs and nothing is
registered. Read it with
Diagnostics.tryGetProfiler from a renderer,
a subscription, or a context taking update.
All members are for the frame thread only. The stamp methods allocate nothing and box nothing, so a host can call them every frame.
Constructors
| Constructor |
Description
|
|
Creates a profiler that cannot take screenshots. Headless hosts use this form.
|
Full Usage:
FrameProfiler(window, canScreenshot)
Parameters:
TimeSpan
canScreenshot : bool
Returns: FrameProfiler
|
|
Instance members
| Instance member |
Description
|
Full Usage:
this.AddSimSteps
Parameters:
int
dropped : bool
|
Counts simulation steps that ran in this frame. The shared loop calls this once per frame. dropped marks that the fixed step hit its step cap and threw time away.
|
Full Usage:
this.BeginDraw
|
Starts the draw phase. Hosts call this right before they draw. Headless
runners never call it, so draw fields stay |
Full Usage:
this.BeginFrame
|
Starts a host frame. Hosts call this first in the frame, before input polling and the update phase. When the window has elapsed, this call first freezes the finished window into FrameProfiler.Snapshot and then starts the next window. |
Full Usage:
this.CanScreenshot
Returns: bool
|
Whether this runtime can capture the screen.
|
Full Usage:
this.DrainScreenshot
Returns: string voption
|
Takes the pending screenshot request, if any. Hosts call this at the end of draw, then write the file themselves.
|
Full Usage:
this.Enabled
Returns: bool
|
Whether measurement runs. On by default. Turn it off and on at any time. While it is off every stamp and every request does nothing. Turning it back on starts a fresh window, so the time spent off never shows up as a frame spike.
|
Full Usage:
this.EndDraw
|
Ends the draw phase. Hosts call this after the last draw call of the frame, before they present. |
Full Usage:
this.EndUpdate
|
Ends the update phase. Hosts call this after the update work of the frame is done, before any drawing. |
Full Usage:
this.NoteSlowFrame
|
Counts one frame that ran behind. MonoGame hosts call this when the fixed step catch up flag is set. |
Full Usage:
this.PublishGpuMetrics
Parameters:
int64
primitives : int64
textureBinds : int64
|
Publishes the graphics counters of the frame that just drew. MonoGame
hosts call this at the end of draw. Other backends never call it, so the
fields stay
|
Full Usage:
this.RequestScreenshot
Parameters:
string
|
Asks the host to save a screenshot at the given path at the end of the current frame. The request does nothing when FrameProfiler.CanScreenshot is false, which is the case on headless runners. Check that property beforehand when the difference matters. The file is written when the frame finishes drawing. The capture reads the whole screen and encodes a PNG, so expect one slow frame per request.
|
|
The measurements of the last completed window. Zeroed out until the first window completes.
|
Static members
| Static member |
Description
|
|
The default measurement window of half a second.
|
Mibo