# End()

> End profiling a piece of code with a custom label.

## Definition

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

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

### Remarks

This will show up in the Profiler hierarchy.

```csharp
using UnityEngine;
using UnityEngine.Profiling;

public class ExampleClass : MonoBehaviour
{
    CustomSampler sampler;
    void Start()
    {
        sampler = CustomSampler.Create("MyCustomSampler");
    }

    void Update()
    {
        sampler.Begin();
        // do something that takes a lot of time
        sampler.End();
    }
}
```

Profiler.BeginSample is conditionally compiled away using ConditionalAttribute. Thus it will have zero overhead, when it is deployed in non-Development Build.

Additional Resources: [CustomSampler.Begin](/engine/6000.7/script-reference/unityengine/profiling/customsampler/begin.md), [CustomSampler.Create](/engine/6000.7/script-reference/unityengine/profiling/customsampler/create.md), [ProfilerCPU](/engine/6000.7/manual/analysis/profiler/visualizing-data/cpu.md).
