class in UnityEngine.Profiling
/
Inherits from:Profiling.Sampler
/
Implemented in:UnityEngine.CoreModule
Custom CPU Profiler label used for profiling arbitrary code blocks.
Use CustomSampler to measure execution time of script code blocks. Produced information is displayed in the CPU Profiler and can be captured with Recorder.
Using CustomSampler is more efficient than using Profiler.BeginSample to profile your code. This is because CustomSamplers that have been created in advance have very low Begin call overhead compared to Profiler.BeginSample.
#pragma strict var sampler: CustomSampler; function Start() { sampler = CustomSampler.Create("MyCustomSampler"); } function Update() { sampler.Begin(); // do something that takes a lot of time sampler.End(); }
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(); } }
CustomSampler.Begin is conditionally compiled away using ConditionalAttribute.
Thus it will have zero overhead, when it is deployed in non-Development Build.
See Also: Sampler, CustomSampler.Create, CustomSampler.Begin.
Begin | Begin profiling a piece of code with a custom label defined by this instance of CustomSampler. |
End | End profiling a piece of code with a custom label. |
Create | Creates a new CustomSampler for profiling parts of your code. |
GetRecorder | Returns Recorder associated with the Sampler. |
Did you find this page useful? Please give it a rating: