public static bool MonitorUpdateDuration <T>(ISveltoTask <T> sveltoTask, string runnerName) where T : IEnumerator { var taskName = sveltoTask.ToString(); #if ENABLE_PIX_EVENTS PixWrapper.PIXBeginEventEx(0x11000000, key); #endif _stopwatch.Value.Start(); var result = sveltoTask.MoveNext(); _stopwatch.Value.Stop(); #if ENABLE_PIX_EVENTS PixWrapper.PIXEndEventEx(); #endif lock (LockObject) { ref var infosPerRunnner = ref taskInfos.GetOrCreate(runnerName, () => new FasterDictionary <string, TaskInfo>()); if (infosPerRunnner.TryGetValue(taskName, out var info) == false) { info = new TaskInfo(taskName, runnerName); infosPerRunnner.Add(taskName, info); } else { info.AddUpdateDuration((float)_stopwatch.Value.Elapsed.TotalMilliseconds); infosPerRunnner[taskName] = info; } }
public static bool MonitorUpdateDuration(IEnumerator tickable, string runnerName) { var key = tickable.ToString().FastConcat(runnerName); #if ENABLE_PIX_EVENTS PixWrapper.PIXBeginEventEx(0x11000000, key); #endif _stopwatch.Start(); var result = tickable.MoveNext(); _stopwatch.Stop(); #if ENABLE_PIX_EVENTS PixWrapper.PIXEndEventEx(); #endif lock (LOCK_OBJECT) { TaskInfo info; if (taskInfos.TryGetValue(key, out info) == false) { info = new TaskInfo(tickable); info.AddThreadInfo(runnerName.FastConcat(": ")); taskInfos.Add(key, ref info); } else { info.AddUpdateDuration(_stopwatch.Elapsed.TotalMilliseconds); taskInfos.Update(key, ref info); } } _stopwatch.Reset(); return(result); }
public static void EndSample() { PixWrapper.PIXEndEventEx(); /*var passed = watch.ElapsedMilliseconds; * * Profiler.EndSample(); * * var l = passed - _current; * times[_name] = times[_name] + l;*/ }
public static bool MonitorUpdateDuration <T #if ENABLE_PLATFORM_PROFILER , PP #endif >(T sveltoTask, string runnerName #if ENABLE_PLATFORM_PROFILER , PP profiler #endif ) where T : ISveltoTask #if ENABLE_PLATFORM_PROFILER where PP : IPlatformProfiler #endif { var key = sveltoTask.ToString().FastConcat(runnerName); bool result; #if ENABLE_PLATFORM_PROFILER using (profiler.Sample(sveltoTask.ToString())) #endif { _stopwatch.Start(); #if ENABLE_PIX_EVENTS PixWrapper.PIXBeginEventEx(0x11000000, key); #endif result = sveltoTask.MoveNext(); #if ENABLE_PIX_EVENTS PixWrapper.PIXEndEventEx(); #endif _stopwatch.Stop(); } lock (LOCK_OBJECT) { if (taskInfos.TryGetValue(key, out var info) == false) { info = new TaskInfo(sveltoTask.ToString()); info.AddThreadInfo(runnerName.FastConcat(": ")); taskInfos.Add(key, ref info); } else { info.AddUpdateDuration(_stopwatch.Elapsed.TotalMilliseconds); taskInfos.Update(key, ref info); } } _stopwatch.Reset(); return(result); }
public static bool MonitorUpdateDuration <T, PP>(ref T sveltoTask, string runnerName, PP profiler) where T : ISveltoTask where PP : IPlatformProfiler { var samplerName = sveltoTask.name; var key = samplerName.FastConcat(runnerName); bool result; using (profiler.Sample(samplerName)) { _stopwatch.Start(); #if ENABLE_PIX_EVENTS PixWrapper.PIXBeginEventEx(0x11000000, key); #endif result = sveltoTask.MoveNext(); #if ENABLE_PIX_EVENTS PixWrapper.PIXEndEventEx(); #endif _stopwatch.Stop(); } lock (LOCK_OBJECT) { if (taskInfos.TryGetValue(key, out var info) == false) { info = new TaskInfo(samplerName); #warning Todo for seb: avoid allocation here please info.AddThreadInfo(runnerName); taskInfos.Add(key, ref info); } else { info.AddUpdateDuration(_stopwatch.Elapsed.TotalMilliseconds); taskInfos.Update(key, ref info); } } _stopwatch.Reset(); return(result); }