Repository URL to install this package:
Version:
1.3.1 ▾
|
using System;
using System.Collections.Generic;
using UnityEngine.Profiling;
namespace Fluctio.FluctioSim.Utils.General
{
public class ProfilerScope : IDisposable
{
private static readonly Dictionary<string, CustomSampler> Samplers = new();
private readonly CustomSampler _sampler;
public ProfilerScope(string key)
{
var samplerExisted = Samplers.TryGetValue(key, out _sampler);
if (!samplerExisted)
{
_sampler = CustomSampler.Create(key);
Samplers[key] = _sampler;
}
_sampler.Begin();
}
public void Dispose()
{
_sampler.End();
}
}
}