Struct ProfilerMarker<TP1>
Use ProfilerMarker<TP1> to mark up script code blocks for the Unity Profiler.
You can pass a single integral or floating point parameter alongside the Begin event.
Namespace: Unity.Profiling
Syntax
public readonly struct ProfilerMarker<TP1>
where TP1 : struct
Type Parameters
Name | Description |
---|---|
TP1 | int, uint, long, ulong, float or double type. |
Constructors
ProfilerMarker(String, String)
Constructs the ProfilerMarker that belongs to the generic ProfilerCategory.Scripts category.
Declaration
public ProfilerMarker(string name, string param1Name)
Parameters
Type | Name | Description |
---|---|---|
String | name | Name of a marker. |
String | param1Name | Name of the first parameter passed to the Begin method. |
Remarks
Does nothing in Release Players.
ProfilerMarker(ProfilerCategory, String, String)
Constructs the ProfilerMarker.
Declaration
public ProfilerMarker(ProfilerCategory category, string name, string param1Name)
Parameters
Type | Name | Description |
---|---|---|
ProfilerCategory | category | Profiler category. |
String | name | Name of a marker. |
String | param1Name | Name of the first parameter passed to the Begin method. |
Remarks
Does nothing in Release Players.
Methods
Auto(TP1)
Profiles a piece of code enclosed within the using statement.
Declaration
public readonly ProfilerMarker<TP1>.AutoScope Auto(TP1 p1)
Parameters
Type | Name | Description |
---|---|---|
TP1 | p1 | Additional context parameter. |
Returns
Type | Description |
---|---|
Unity.Profiling.ProfilerMarker.AutoScope<> | IDisposable struct which calls End on Dispose. |
Remarks
Returns null in Release Players.
Examples
using (profilerMarker.Auto(enemies.Count))
{
var blastRadius2 = blastRadius * blastRadius;
for (int i = 0; i < enemies.Count; ++i)
{
var r2 = (enemies[i].Pos - blastPos).sqrMagnitude;
if (r2 < blastRadius2)
enemies[i].Dispose();
}
}
Begin(TP1)
Begins profiling a piece of code marked with the ProfilerMarker instance.
Declaration
public readonly void Begin(TP1 p1)
Parameters
Type | Name | Description |
---|---|---|
TP1 | p1 | Additional context parameter. |
Remarks
Does nothing in Release Players.
End()
Ends profiling a piece of code marked with the ProfilerMarker instance.
Declaration
public readonly void End()
Remarks
Does nothing in Release Players.