public static class ProfilerScoped CPU sampling. Samples go into a per-thread ring, so recording one is a handful of stores with no lock, no allocation and no contention.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Meant to be left on. A profiler you have to enable is a profiler that is off when the bug happens. The cost of an inactive scope is one volatile read; the cost of an active one is a timestamp pair and a ring write. Build with VIXEN_NO_PROFILER to remove even that.
Rings overwrite, so a thread that samples heavily and is never collected keeps its most recent history rather than growing. DroppedSampleCount says how much went over the side, because a truncated trace that does not admit it is worse than no trace.
Fields and properties (6)
public const bool IsSupportedWhether this build can sample at all. A compile-time constant.
public const int DefaultCapacityPerThreadHow many samples each thread's ring holds before it starts overwriting.
public static bool IsEnabledWhether scopes are being recorded. A single volatile read on the hot path, which is what makes leaving the instrumentation compiled in affordable.
public static int FrameIndexThe frame samples are currently being attributed to.
public static int CapacityPerThreadHow many samples each thread's ring holds. Takes effect for threads not yet seen.
public static long DroppedSampleCountHow many samples have been overwritten before anybody collected them.
Methods (4)
public static Profiler.Scope Begin(ProfilingKey key)Opens a scope. Dispose it — or let using do so — to record the sample.
public static int BeginFrame()Advances the frame counter that later samples are attributed to.
public static ProfilerThreadSamples[] Collect()Copies out every thread's samples and empties the rings.
public static void Reset()Discards every recorded sample and forgets every thread that has recorded one.
Used by (7)
- DiagnosticsTestsVixen.Core.Diagnostics.Tests
- FrameGraphOverlayVixen.Engine
- JobSchedulerVixen.Core.Threading
- ScopeVixen.Core.Diagnostics
- DiagnosticsPanelTestsVixen.Editor.App.Tests
- EditorHostVixen.Editor.Host
- LocalProfileSourceVixen.Editor.Profiler