# ProfilerMarker

> Constructs a new performance marker for code instrumentation.

## Definition

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

## ProfilerMarker(string)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(string name)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Marker name.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(char\*, int)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(char* name, int nameLen)
```

### Parameters

**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): Marker name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Marker name length.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(ProfilerCategory, string)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(ProfilerCategory category, string name)
```

### Parameters

**** (\[ProfilerCategory]\(/engine/6000.3/script-reference/unity/profiling/profilercategory)): Profiler category.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Marker name.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(ProfilerCategory, char\*, int)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(ProfilerCategory category, char* name, int nameLen)
```

### Parameters

**** (\[ProfilerCategory]\(/engine/6000.3/script-reference/unity/profiling/profilercategory)): Profiler category.**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): Marker name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Marker name length.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(string, MarkerFlags)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(string name, MarkerFlags flags)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Marker name.**** (\[MarkerFlags]\(/engine/6000.3/script-reference/unity/profiling/lowlevel/markerflags)): The marker flags.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(char\*, int, MarkerFlags)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(char* name, int nameLen, MarkerFlags flags)
```

### Parameters

**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): Marker name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Marker name length.**** (\[MarkerFlags]\(/engine/6000.3/script-reference/unity/profiling/lowlevel/markerflags)): The marker flags.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(ProfilerCategory, string, MarkerFlags)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(ProfilerCategory category, string name, MarkerFlags flags)
```

### Parameters

**** (\[ProfilerCategory]\(/engine/6000.3/script-reference/unity/profiling/profilercategory)): Profiler category.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Marker name.**** (\[MarkerFlags]\(/engine/6000.3/script-reference/unity/profiling/lowlevel/markerflags)): The marker flags.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```

## ProfilerMarker(ProfilerCategory, char\*, int, MarkerFlags)

Constructs a new performance marker for code instrumentation.

```csharp
public ProfilerMarker(ProfilerCategory category, char* name, int nameLen, MarkerFlags flags)
```

### Parameters

**** (\[ProfilerCategory]\(/engine/6000.3/script-reference/unity/profiling/profilercategory)): Profiler category.**** (\[char\*]\(https\://learn.microsoft.com/dotnet/api/system.char)): Marker name.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Marker name length.**** (\[MarkerFlags]\(/engine/6000.3/script-reference/unity/profiling/lowlevel/markerflags)): The marker flags.

### Remarks

Use *ProfilerMarker* to markup a piece of code for the Profiler and [Recorder](/engine/6000.3/script-reference/unityengine/profiling/recorder.md).

### Examples

```csharp
using Unity.Profiling;

public class MySystemClass
{
    static readonly ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare");
    static readonly ProfilerMarker s_SimulatePerfMarker = new ProfilerMarker(ProfilerCategory.Ai, "MySystem.Simulate");

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

        using (s_SimulatePerfMarker.Auto())
        {
            // ...
        }
    }
}
```
