public static ProfileBlock Start(string sampleNameFormat, object obj) { #if ZEN_TESTS_OUTSIDE_UNITY return(null); #else if (UnityMainThread == null || !UnityMainThread.Equals(System.Threading.Thread.CurrentThread)) { return(null); } if (!Profiler.enabled) { return(null); } // We need to ensure that we do not have per-frame allocations in ProfileBlock // to avoid infecting the test too much, so use a cache of formatted strings given // the input values // This only works if the input values do not change per frame var hash = GetHashCode(sampleNameFormat, obj); string formatString; if (!_nameCache.TryGetValue(hash, out formatString)) { formatString = string.Format(sampleNameFormat, obj); _nameCache.Add(hash, formatString); } return(StartInternal(formatString)); #endif }
public static ProfileBlock Start(string sampleName) { #if ZEN_TESTS_OUTSIDE_UNITY return(null); #else if (UnityMainThread == null || !UnityMainThread.Equals(System.Threading.Thread.CurrentThread)) { return(null); } if (!Profiler.enabled) { return(null); } return(StartInternal(sampleName)); #endif }