# ProfilerMarker.AutoScope

> Helper IDisposable struct for use with ProfilerMarker.Auto.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Profiling](/engine/6000.0/script-reference/unity/profiling.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct ProfilerMarker.AutoScope : IDisposable
```

## Remarks

Use [ProfilerMarker.Auto](/engine/6000.0/script-reference/unity/profiling/profilermarker/auto.md) to enclose a piece of code you want to profile in *using* statement. Constructor of *AutoScope* calls [ProfilerMarker.Begin](/engine/6000.0/script-reference/unity/profiling/profilermarker/begin.md) and *Dispose* method - [ProfilerMarker.Begin](/engine/6000.0/script-reference/unity/profiling/profilermarker/begin.md).

## Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    ProfilerMarker simulatePerfMarker = new ProfilerMarker("MySystem.Simulate");

    public void UpdateLogic()
    {
        using (simulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```
