Begin
Begin profiling a piece of code marked with a custom name defined by this instance of ProfilerMarker.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: Unity.Profiling
- Assembly: UnityEngine.CoreModule
Begin()
Begin profiling a piece of code marked with a custom name defined by this instance of ProfilerMarker.
[Conditional("ENABLE_PROFILER")]public void Begin()
Remarks
Always use ProfilerMarker.End to close a started section of an instrumented code.
Code marked with ProfilerMarker.Begin and ProfilerMarker.End will show up in the Profiler hierarchy. Use Recorder to obtain per-frame timings in the Player.
Note: Both ProfilerMarker.Begin and ProfilerMarker.End are thread safe and can be used in jobified code.
using Unity.Profiling;public class MySystemClass{ static ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare"); public void UpdateLogic() { s_PreparePerfMarker.Begin(); // ... s_PreparePerfMarker.End(); }}
ProfilerMarker.Begin is conditionally compiled away using ConditionalAttribute. Thus it will have zero overhead, when it is deployed in non-Development Build.
Begin(Object)
Begin profiling a piece of code marked with a custom name defined by this instance of ProfilerMarker.
[Conditional("ENABLE_PROFILER")]public void Begin(Object contextUnityObject)
Parameters
Object associated with the operation.
Remarks
Always use ProfilerMarker.End to close a started section of an instrumented code.
Code marked with ProfilerMarker.Begin and ProfilerMarker.End will show up in the Profiler hierarchy. Use Recorder to obtain per-frame timings in the Player.
Note: Both ProfilerMarker.Begin and ProfilerMarker.End are thread safe and can be used in jobified code.
using Unity.Profiling;public class MySystemClass{ static ProfilerMarker s_PreparePerfMarker = new ProfilerMarker("MySystem.Prepare"); public void UpdateLogic() { s_PreparePerfMarker.Begin(); // ... s_PreparePerfMarker.End(); }}
ProfilerMarker.Begin is conditionally compiled away using ConditionalAttribute. Thus it will have zero overhead, when it is deployed in non-Development Build.