# HG changeset patch # User Alys Brooks # Date 2022-05-16 05:09:28 # Node ID 3b7b6298ad9c8be757bbc30d99cc7b5a27ba796f # Parent 88bac2f63baaeef3a2bb014a086bac2c7f8b2aca Add timers for Simulation and various engines Starting to add additional timers for different stages of the process of updating in order to get more insight into what is slowing it down. The update takes 9ms, which is much longer than it used to. Engine-specific timers are coming later. diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -62,6 +62,8 @@ TimeSpan gridDrawTime = TimeSpan.Zero; TimeSpan treeDrawTime = TimeSpan.Zero; TimeSpan updateTime = TimeSpan.Zero; + TimeSpan worldUpdateTime = TimeSpan.Zero; + TimeSpan simulationUpdateTime = TimeSpan.Zero; Queue past_fps = new Queue(100); Queue past_draw = new Queue(100); @@ -479,6 +481,7 @@ protected override void Update(GameTime gameTime) { Stopwatch stopWatch = new Stopwatch(); + Stopwatch stopWatch2 = new Stopwatch(); stopWatch.Start(); #if DEBUG @@ -504,8 +507,16 @@ #endregion misc_keys #endregion input + stopWatch2.Start(); World.Update(gameTime.ElapsedGameTime.TotalSeconds); + stopWatch2.Stop(); + this.worldUpdateTime = stopWatch2.Elapsed; + + stopWatch2 = new Stopwatch(); + stopWatch2.Start(); this.simulation.update(gameTime.ElapsedGameTime); + stopWatch2.Stop(); + this.simulationUpdateTime = stopWatch2.Elapsed; if (this.showBudget) { @@ -976,6 +987,8 @@ gridDrawTime = this.gridDrawTime, tileDrawTime = this.tileDrawTime, updateTime = this.updateTime, + worldUpdateTime = this.worldUpdateTime, + simulationUpdateTime = this.simulationUpdateTime, treeCount = this.simulation.map.tree_count, mouseGrid = this.mouseGrid, hasTree = has_tree, diff --git a/isometric-park-fna/UI/DebugWindow.cs b/isometric-park-fna/UI/DebugWindow.cs --- a/isometric-park-fna/UI/DebugWindow.cs +++ b/isometric-park-fna/UI/DebugWindow.cs @@ -26,6 +26,9 @@ public Boolean hasTree; public int tilesDrawn; public TimeSpan updateTime; + public TimeSpan worldUpdateTime; + public TimeSpan simulationUpdateTime; + } public class DebugWindow @@ -232,6 +235,9 @@ debugInfo.gridDrawTime.TotalMilliseconds.ToString(), debugInfo.tileDrawTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); + ImGui.Text(string.Format("\tWorld: {0:F3}; Simulation: {1:F3}", + debugInfo.worldUpdateTime.TotalMilliseconds.ToString(), + debugInfo.simulationUpdateTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn));