You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB
C#

#if (UNITY_EDITOR || DEVELOPMENT_BUILD) && !UPDATE_MANAGER_DISABLE_PROFILER_MARKERS
#define ENABLE_PROFILER_MARKERS
#endif
using System;
using System.Collections.Generic;
using Unity.Profiling;
namespace LanLib.UpdateManager.Internal
{
public static class ProfilerMarkerMap
{
#if ENABLE_PROFILER_MARKERS
public static ProfilerMarker.AutoScope Get(string method, object obj)
{
Type type = obj.GetType();
var key = (type, method);
if (!_profileMarkerCache.TryGetValue(key, out ProfilerMarker profilerMarker))
{
profilerMarker = new ProfilerMarker(type.Name + "." + method + "()");
_profileMarkerCache[key] = profilerMarker;
}
return profilerMarker.Auto();
}
private readonly static Dictionary<(Type, string), ProfilerMarker> _profileMarkerCache =
new Dictionary<(Type, string), ProfilerMarker>();
#else
public static IDisposable Get(string method, object obj)
{
return null;
}
#endif
}
}