Skip to content

KernelAPI reference

Class GameDiagnostics

Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time

The game’s live measurements (Diagnostics): the last frame’s times, allocations, collections, graphics work and audio voices, and the time of every system of the frame schedule. Off by default; a run measures while Enabled is set or while a tool listens to the engine’s meter (MeterName), and costs nothing measurable otherwise.

C#
public sealed class GameDiagnostics

Inheritance

object ← GameDiagnostics

Examples

C#
// In Load: measure, and show the numbers when F3 is held.
Diagnostics.Enabled = true;
// In DrawAboveScenes:
var frame = Diagnostics.LastFrame;
Font.Draw(renderer, $"{frame.Total:0.0} ms {frame.Graphics.DrawCalls} draws {frame.Allocated} B", new Vector2(4, 4), Color.White);

Remarks

The same numbers are published as Metrics instruments of the meter “MicroEngine”, so dotnet-counters monitor –counters MicroEngine, dotnet-monitor or an OpenTelemetry exporter read them without code in the game. The runtime’s own meter (System.Runtime) adds the heap size, GC pauses and thread-pool figures.

Fields

MeterName

The name of the engine’s meter (Meter): “MicroEngine”.

C#
public const string MeterName = "MicroEngine"

Field Value

string

Properties

Active

Whether frames are measured now: Enabled, or a listener of the engine’s meter is attached.

C#
public bool Active { get; }

Property Value

bool

Enabled

Whether the game measures every frame. Off by default; a tool listening to the engine’s meter measures too (Active).

C#
public bool Enabled { get; set; }

Property Value

bool

LastFrame

The last measured frame; default (frame 0) until a frame is measured. During an update it is the previous frame.

C#
public FrameStatistics LastFrame { get; }

Property Value

FrameStatistics

Systems

Every system of the frame schedule with its time during the last measured frame, in the order phases run and, within a phase, in the order its systems run. Empty until a frame is measured.

C#
public IReadOnlyList<SystemTiming> Systems { get; }

Property Value

IReadOnlyList<SystemTiming>