Vixen
02b45cc4
csharp
public readonly record struct ProfilingKey

A pre-registered, interned name for something worth timing. An Int32 at run time; a readable name only when a report is written.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

The reason a profiler can be left on. A sample carries this and two timestamps, so recording one is a few stores into a ring — no string, no dictionary, no allocation. Resolving the name happens once, when a trace is exported, by which time nobody cares what it costs.

Declare keys in a static class per subsystem, so registration happens once at type initialisation rather than in the loop being measured:

static class RenderKeys { public static readonly ProfilingKey Culling = ProfilingKey.Register("Render.Culling"); }

Fields and properties (5)

  • public int Id
  • public static ProfilingKey None

    The key that names nothing, and the value of an uninitialised key.

  • public bool IsValid

    Whether this names a registered scope.

  • public string Name

    The registered name, or "<none>".

  • public static int RegisteredCount

    How many keys have been registered.

Methods (9)

  • public ProfilingKey(int Id)

    A pre-registered, interned name for something worth timing. An Int32 at run time; a readable name only when a report is written.

  • public static ProfilingKey Register(string name)

    Interns a name, returning the same key every time. Safe to call from several threads and safe to call repeatedly; the intended use is once, from a static field initialiser.

  • public static bool TryGet(string name, out ProfilingKey key)

    Looks up an already-registered key.

  • public int CompareTo(ProfilingKey other)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

  • public static bool operator <(ProfilingKey left, ProfilingKey right)

    Whether sorts before .

  • public static bool operator <=(ProfilingKey left, ProfilingKey right)

    Whether sorts before or equal to .

  • public static bool operator >(ProfilingKey left, ProfilingKey right)

    Whether sorts after .

  • public static bool operator >=(ProfilingKey left, ProfilingKey right)

    Whether sorts after or equal to .

  • public override string ToString()

    The registered name.

Used by (19)

  • DiagnosticsTestsVixen.Core.Diagnostics.Tests
  • FrameGraphOverlayVixen.Engine
  • JobPayloadStoreVixen.Core.Threading
  • ParallelJobTypeVixen.Core.Threading
  • ProfilerVixen.Core.Diagnostics
  • ProfilerSampleVixen.Core.Diagnostics
  • ScopeVixen.Core.Diagnostics
  • SequentialJobTypeVixen.Core.Threading
  • TraceExporterVixen.Core.Diagnostics
  • CaptureComparisonVixen.Editor.Profiler
  • CaptureTestsVixen.Editor.Profiler.Tests
  • EditorKeysVixen.Editor.App
  • FlameChartViewTestsVixen.Editor.Profiler.Tests
  • FlameNodeVixen.Editor.Profiler
  • FlameTreeTestsVixen.Editor.Profiler.Tests
  • ProfileDeltaVixen.Editor.Profiler
  • ProfileEntryVixen.Editor.Profiler
  • ProfileSummaryVixen.Editor.Profiler
  • ProfilerModelTestsVixen.Editor.Profiler.Tests