# Create(string, bool)

> Creates a new CustomSampler for profiling parts of your code.

## Definition

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

```csharp
public static CustomSampler Create(string name, bool collectGpuData = false)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the Sampler.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): Specifies whether this Sampler records GPU timings. If you want the Sampler to record GPU timings, set this to true.

### Returns

| Type                                                                                    | Description                                                                                                                                               |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [CustomSampler](/engine/6000.7/script-reference/unityengine/profiling/customsampler.md) | [CustomSampler](/engine/6000.7/script-reference/unityengine/profiling/customsampler.md) object or *null* if a built-in Sampler with the same name exists. |

### Remarks

Multiple calls with the same *name* parameter return different [CustomSampler](/engine/6000.7/script-reference/unityengine/profiling/customsampler.md) objects which refer to the same native representation. CustomSampler represents scripting profiler label.

Method throws **ArgumentNullException** when used with *null* string.

```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();
    }
}
```

Additional Resources: [CustomSampler.Begin](/engine/6000.7/script-reference/unityengine/profiling/customsampler/begin.md), [Sampler.Get](/engine/6000.7/script-reference/unityengine/profiling/sampler/get.md).
