# End()

> End profiling a piece of code marked with a custom name defined by this instance of ProfilerMarker.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Profiling](/engine/6000.3/script-reference/unity/profiling.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
[Conditional("ENABLE_PROFILER")]
public void End()
```

### Remarks

Always use [ProfilerMarker.Begin](/engine/6000.3/script-reference/unity/profiling/profilermarker/begin.md) to start a section of an instrumented code.

Code marked with [ProfilerMarker.Begin](/engine/6000.3/script-reference/unity/profiling/profilermarker/begin.md) and [ProfilerMarker.End](/engine/6000.3/script-reference/unity/profiling/profilermarker/end.md) will show up in the Profiler hierarchy. Use [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md) to obtain per-frame timings in the Player.

**Note:** Both [ProfilerMarker.Begin](/engine/6000.3/script-reference/unity/profiling/profilermarker/begin.md) and [ProfilerMarker.End](/engine/6000.3/script-reference/unity/profiling/profilermarker/end.md) are thread safe and can be used in jobified code.

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");

    public void UpdateLogic()
    {
        s_PreparePerfMarker.Begin();
        // ...
        s_PreparePerfMarker.End();
    }
}
```

[ProfilerMarker.End](/engine/6000.3/script-reference/unity/profiling/profilermarker/end.md) is conditionally compiled away using ConditionalAttribute. Thus it will have zero overhead, when it is deployed in non-Development Build.

Additional Resources: [ProfilerMarker.Begin](/engine/6000.3/script-reference/unity/profiling/profilermarker/begin.md), [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md), [ProfilerCPU](/engine/6000.3/manual/analysis/profiler/visualizing-data/cpu.md).
