using System;
using UnityEngine.Profiling;
namespace UnityEngine.XR.ARSubsystems
{
///
/// An `IDisposable` [profiler](https://docs.unity3d.com/ScriptReference/Profiling.Profiler.html)
/// object that will begin a profiler sample on instantiation and end the same when disposed.
///
///
///
/// using (new ScopedProfiler("MySample"))
/// {
/// CodeToProfile();
/// }
///
///
public struct ScopedProfiler : IDisposable
{
///
/// Begins a new profiler sample. Same as [Profiler.BeginSample](https://docs.unity3d.com/ScriptReference/Profiling.Profiler.BeginSample.html).
///
/// A string to identify the sample in the Profiler window.
public ScopedProfiler(string name) => Profiler.BeginSample(name);
///
/// Begins a new profiler sample. Same as [Profiler.BeginSample](https://docs.unity3d.com/ScriptReference/Profiling.Profiler.BeginSample.html).
///
/// A string to identify the sample in the Profiler window.
/// An object that provides context to the sample.
public ScopedProfiler(string name, UnityEngine.Object targetObject) => Profiler.BeginSample(name, targetObject);
///
/// Ends the current profiling sample. Same as [Profiler.EndSample](https://docs.unity3d.com/ScriptReference/Profiling.Profiler.EndSample.html).
///
public void Dispose() => Profiler.EndSample();
}
}