Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ai.fluctio.fluctio-sim / Utils / General / ProfilerScope.cs
Size: Mime:
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();
		}
	}
}