Skip to main content
Search our knowledge base

How can I profile a specific part of my code?

Comments

3 comments

  • Martin Tilo Schmitz

    Using ProfilerMarker instead of Profiler.BeginSample/EndSample comes with less overhead for profiling and can be used in a using scope to avoid missing an EndSample call when returning earlier in the block or an exception getting thrown.

    2
  • Manjit Bedi

    What is the user statement required? I get an error when I try to compile the code:

    error CS0103: The name 'Profiling' does not exist in the current context
    0
  • Martin Tilo Schmitz

    Manjit Bedi
    ProfilerMarkers require a

    using Unity.Profiling;

    to include the namespace they reside in, or

    static readonly Unity.Profiling.ProfilerMarker s_MyProfilerMarker = new Unity.Profiling.ProfilerMarker("My Profiler Marker");

    For more details please see the scripting documentation page for ProfilerMarkers.

    0

Please sign in to leave a comment.