ProfilerMarkers
Profiler markers in one line, with no fields or names to keep up by hand.
Quick start
| Before — Unity API | After — FastTools |
|---|---|
| |
Marker()
The marker name includes the type, the member name and the call’s line number:
Where this.Marker() is called | Marker name |
|---|---|
void Step() | FlockSimulation.Step (line) |
FlockSimulation() | FlockSimulation.Ctor (line) |
float Speed { get; } | FlockSimulation.Speed (line) |
Agent this[int i] { get; } | FlockSimulation.Indexer (line) |
event Action Changed | FlockSimulation.Changed (line) |
Explicit implementation void ISimulation.Step() | FlockSimulation.Step (line) |
The line number changes when the call moves in the source.
Nested and generic types
| Call location | Marker name |
|---|---|
Method Move() in nested FlockSimulation.Agent | Agent.Move (line) |
Step() in class FlockSimulation<Int32> | FlockSimulation<Int32>.Step (line) |
Step() in struct FlockSimulation<T> | FlockSimulation<T>.Step (line) for any T |
Generic method Step<T>() | FlockSimulation.Step (line) for any T |
WithName()
WithName("Steering") replaces the member name, keeping the type and line number.
public void Step()
{
using var _ = this.Marker();
using (this.Marker().WithName("Steering"))
{
foreach (var agent in _agents)
{
using (this.Marker().WithName("Steering.Agent"))
ComputeSteering(agent);
}
}
using (this.Marker().WithName("Integrate"))
Integrate();
}
The name must be a constant: a string literal, a const, nameof or a string built from them. A name known only at run time leaves the member name.
In the Profiler
Markers are created once. After initialization, repeated measurements allocate no memory. In a player build without Development Build, this.Marker() measures nothing: ENABLE_PROFILER is not defined.
Package markers
The package marks its own hot paths too, such as the first access to EnumValues, which builds its entries, and SerializableType resolution. Lookups in an already built EnumValues open no marker. Add the symbol ASPID_FASTTOOLS_UNITY_PROFILER_DISABLED to Scripting Define Symbols to compile these markers out. Markers from your own this.Marker() calls stay.
Limitations
- Call
this.Marker()inside its own type. Calls on another type’s instance, in a static class or in aprivate/protectednested type are unreliable: the measurement may be missing or use another call’s marker. Marker()is declared without a namespace, so it needs nousingand code completion offers it on any expression, even when the call gets no marker.- Use
using. A standalonethis.Marker();starts a measurement without ending it. - End the
usingbeforeyield returnorawait. A coroutine or anasyncmethod resumes in a later frame or on another thread, so a measurement left open across them leaves the Profiler samples unbalanced.
Calls within one type that share a line number share a marker, even across different partial files. Give each call site a distinct line number, or measurements will be combined under the first call’s name.
Package sample
The markers from WithName() run in the ProfilerMarkers scene.

