public static void BeginFrame() { if (DwarfGame.IsConsoleVisible) { CurrentFrame = null; Functions.Clear(); __pushFrame("Root"); } }
public static void PopFrame() { if (DwarfGame.IsConsoleVisible && CurrentFrame != null) { CurrentFrame.Stopwatch.Stop(); CurrentFrame.Ticks = CurrentFrame.Stopwatch.ElapsedTicks; CurrentFrame.Function.FrameTicks += CurrentFrame.Ticks; CurrentFrame = CurrentFrame.ParentFrame; } }
private static void __pushFrame(String Name) { PerformanceFunction Function; if (!Functions.TryGetValue(Name, out Function)) { Function = new PerformanceFunction { Name = Name }; Functions.Add(Name, Function); } Function.FrameCalls += 1; CurrentFrame = new PerformanceFrame { ParentFrame = CurrentFrame, Stopwatch = Stopwatch.StartNew(), Function = Function }; }