ProfilerMarkers Sample
A flock of cubes whose every frame phase shows up in the Profiler under its own name.


The flock simulation whose phases the markers measure.
Open it
- Import the sample: Tools → Aspid 🐍 → FastTools → Welcome → Samples → Import on ProfilerMarkers.
- Open
Scenes/ProfilerMarkers.unityand Window → Analysis → Profiler, enter Play Mode and select a frame in the CPU module. - In the Hierarchy view, expand
PlayerLoopdown toFlock.Update (22).
Try


The markers under Flock.Update nest like the code; FlockSimulation.Steering.Agent has 120 calls for 120 agents.
-
The tree follows the
usingscopes. Nothing else sets the nesting:public void Step(float deltaTime, float neighborRadius, float maxSpeed){using var _ = this.Marker();using (this.Marker().WithName("Steering"))ComputeSteering(neighborRadius);using (this.Marker().WithName("Integrate"))Integrate(deltaTime: deltaTime, maxSpeed: maxSpeed);} -
One marker per loop.
FlockSimulation.Steering.Agentsits in the loop over the agents: one row, withCallsequal to the agent count. -
More agents. In Play Mode, set Count on Flock to
400:Callsbecomes400. -
Not only MonoBehaviour.
FlockSimulationis a plain C# class. The marker in the local functionCreateAgenttakes the method's name,Flock.InitializeAgents (58), and shows up in the frame where Count changes. -
The line number in the name. Every name ends with the line of its call,
FlockSimulation.Steering (37), so two markers in one method never share a name. -
Release builds. In a player build without Development Build the markers measure nothing.
Where to look
| File | Shows |
|---|---|
Scripts/FlockSimulation.cs | Method, block and per-iteration markers in a plain class |
Scripts/Flock.cs | A marker in a local function |
Reference: ProfilerMarkers.