Description:
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.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -62,6 +62,8 | |||||
|
62 | TimeSpan gridDrawTime = TimeSpan.Zero; |
|
62 | TimeSpan gridDrawTime = TimeSpan.Zero; |
|
63 | TimeSpan treeDrawTime = TimeSpan.Zero; |
|
63 | TimeSpan treeDrawTime = TimeSpan.Zero; |
|
64 | TimeSpan updateTime = TimeSpan.Zero; |
|
64 | TimeSpan updateTime = TimeSpan.Zero; |
|
|
65 | TimeSpan worldUpdateTime = TimeSpan.Zero; | ||
|
|
66 | TimeSpan simulationUpdateTime = TimeSpan.Zero; | ||
|
65 |
|
67 | ||
|
66 | Queue<float> past_fps = new Queue<float>(100); |
|
68 | Queue<float> past_fps = new Queue<float>(100); |
|
67 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
69 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
@@ -479,6 +481,7 | |||||
|
479 | protected override void Update(GameTime gameTime) |
|
481 | protected override void Update(GameTime gameTime) |
|
480 | { |
|
482 | { |
|
481 | Stopwatch stopWatch = new Stopwatch(); |
|
483 | Stopwatch stopWatch = new Stopwatch(); |
|
|
484 | Stopwatch stopWatch2 = new Stopwatch(); | ||
|
482 | stopWatch.Start(); |
|
485 | stopWatch.Start(); |
|
483 |
|
486 | ||
|
484 | #if DEBUG |
|
487 | #if DEBUG |
@@ -504,8 +507,16 | |||||
|
504 | #endregion misc_keys |
|
507 | #endregion misc_keys |
|
505 | #endregion input |
|
508 | #endregion input |
|
506 |
|
509 | ||
|
|
510 | stopWatch2.Start(); | ||
|
507 | World.Update(gameTime.ElapsedGameTime.TotalSeconds); |
|
511 | World.Update(gameTime.ElapsedGameTime.TotalSeconds); |
|
|
512 | stopWatch2.Stop(); | ||
|
|
513 | this.worldUpdateTime = stopWatch2.Elapsed; | ||
|
|
514 | |||
|
|
515 | stopWatch2 = new Stopwatch(); | ||
|
|
516 | stopWatch2.Start(); | ||
|
508 | this.simulation.update(gameTime.ElapsedGameTime); |
|
517 | this.simulation.update(gameTime.ElapsedGameTime); |
|
|
518 | stopWatch2.Stop(); | ||
|
|
519 | this.simulationUpdateTime = stopWatch2.Elapsed; | ||
|
509 |
|
520 | ||
|
510 | if (this.showBudget) |
|
521 | if (this.showBudget) |
|
511 | { |
|
522 | { |
@@ -976,6 +987,8 | |||||
|
976 | gridDrawTime = this.gridDrawTime, |
|
987 | gridDrawTime = this.gridDrawTime, |
|
977 | tileDrawTime = this.tileDrawTime, |
|
988 | tileDrawTime = this.tileDrawTime, |
|
978 | updateTime = this.updateTime, |
|
989 | updateTime = this.updateTime, |
|
|
990 | worldUpdateTime = this.worldUpdateTime, | ||
|
|
991 | simulationUpdateTime = this.simulationUpdateTime, | ||
|
979 | treeCount = this.simulation.map.tree_count, |
|
992 | treeCount = this.simulation.map.tree_count, |
|
980 | mouseGrid = this.mouseGrid, |
|
993 | mouseGrid = this.mouseGrid, |
|
981 | hasTree = has_tree, |
|
994 | hasTree = has_tree, |
@@ -26,6 +26,9 | |||||
|
26 | public Boolean hasTree; |
|
26 | public Boolean hasTree; |
|
27 | public int tilesDrawn; |
|
27 | public int tilesDrawn; |
|
28 | public TimeSpan updateTime; |
|
28 | public TimeSpan updateTime; |
|
|
29 | public TimeSpan worldUpdateTime; | ||
|
|
30 | public TimeSpan simulationUpdateTime; | ||
|
|
31 | |||
|
29 | } |
|
32 | } |
|
30 |
|
33 | ||
|
31 | public class DebugWindow |
|
34 | public class DebugWindow |
@@ -232,6 +235,9 | |||||
|
232 | debugInfo.gridDrawTime.TotalMilliseconds.ToString(), |
|
235 | debugInfo.gridDrawTime.TotalMilliseconds.ToString(), |
|
233 | debugInfo.tileDrawTime.TotalMilliseconds.ToString())); |
|
236 | debugInfo.tileDrawTime.TotalMilliseconds.ToString())); |
|
234 | ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); |
|
237 | ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); |
|
|
238 | ImGui.Text(string.Format("\tWorld: {0:F3}; Simulation: {1:F3}", | ||
|
|
239 | debugInfo.worldUpdateTime.TotalMilliseconds.ToString(), | ||
|
|
240 | debugInfo.simulationUpdateTime.TotalMilliseconds.ToString())); | ||
|
235 | ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn)); |
|
241 | ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn)); |
|
236 |
|
242 | ||
|
237 |
|
243 |
You need to be logged in to leave comments.
Login now