KernelAPI reference
Class FrameProfiler
Namespace: MicroEngine.Core
Assembly: MicroEngine.dll
Guide: Game lifecycle and time
Measures a run frame by frame and the phases of its start, for –profile and benchmarks. It only measures
what the engine itself sees: when EndFrame returns, not when the display shows the frame
(presentation times need the platform’s own tools). Samples go into a buffer allocated up front, so profiling
adds no allocations to the frames it measures; a run without a profiler does not measure anything.
public sealed class FrameProfilerInheritance
Constructors
FrameProfiler(int)
Creates a profiler that keeps the last capacity frames (36,000 by default: ten minutes at 60 frames per second).
public FrameProfiler(int capacity = 36000)Parameters
capacity int
Properties
DisplayRate
The refresh rate of the display pacing the run (IDisplayPacing), or 0 when unknown. With it, motion is judged against the whole refresh periods each frame stayed on screen rather than against the loop’s irregular wake-ups; the loop sets it when the run starts.
public double DisplayRate { get; set; }Property Value
Environment
Free-form facts about the run (machine, platform, renderer, display), written with the results.
public IDictionary<string, string> Environment { get; }Property Value
FrameCount
Frames measured since the start (including those no longer kept).
public long FrameCount { get; }Property Value
Phases
The start phases recorded with Phase, in order, with their durations in milliseconds.
public IReadOnlyList<(string Phase, double Milliseconds)> Phases { get; }Property Value
IReadOnlyList<(string Phase, double Milliseconds)>
Samples
The kept frames, oldest first.
public IReadOnlyList<FrameSample> Samples { get; }Property Value
Methods
Add(in FrameSample)
Records a frame.
public void Add(in FrameSample sample)Parameters
sample FrameSample
Phase(string)
Ends the current start phase: records the time since the previous phase ended (or since the profiler was created) under name.
public void Phase(string name)Parameters
name string
Save(string, int)
Writes ToJson to path, or ToCsv when it ends in “.csv”.
public void Save(string path, int warmup = 0)Parameters
path string
warmup int
Summarize(int)
Statistics of the kept frames, skipping the first warmup (start-up and JIT).
public FrameSummary Summarize(int warmup = 0)Parameters
warmup int
Returns
ToCsv()
Every kept frame as CSV, one row per frame.
public string ToCsv()Returns
ToJson(int)
The results as JSON: environment, start phases, summary and every kept frame.
public string ToJson(int warmup = 0)Parameters
warmup int