Description:
Streamline performance of debug code.
Use raw floats for draw times and avoid resorting so many times.
Seems to reduce time by about a third. Still ends up slow after leaving the game running for a few minutes.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -11,6 +11,7 | |||
|
11 | 11 | using System.Collections.Generic; |
|
12 | 12 | using System.Linq; |
|
13 | 13 | using SpriteFontPlus; |
|
14 | using JM.LinqFaster; | |
|
14 | 15 | |
|
15 | 16 | using isometricparkfna; |
|
16 | 17 | using static isometricparkfna.CellMap; |
@@ -70,6 +71,7 | |||
|
70 | 71 | |
|
71 | 72 | Queue<float> past_fps = new Queue<float>(100); |
|
72 | 73 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
74 | Queue<float> past_draw_millis = new Queue<float>(100); | |
|
73 | 75 | int tilesDrawn = 0; |
|
74 | 76 | |
|
75 | 77 | private static int width = 1280; |
@@ -995,6 +997,7 | |||
|
995 | 997 | stopWatch2.Start(); |
|
996 | 998 | //Calcs for debug window: |
|
997 | 999 | past_draw.Enqueue(this.drawTime); |
|
1000 | past_draw_millis.Enqueue((float)this.drawTime.TotalMilliseconds); | |
|
998 | 1001 | if ((this.frameCounter % 15) == 0) |
|
999 | 1002 | { |
|
1000 | 1003 | past_fps.Enqueue(this.frameRate); |
@@ -1072,15 +1075,18 | |||
|
1072 | 1075 | additionalInfo.Add("Dialog entries", entries); |
|
1073 | 1076 | additionalInfo.Add("Metadata entries", descriptions); |
|
1074 | 1077 | |
|
1075 | if (past_fps.Count() > 5) { | |
|
1076 | additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.0001f).ToString()); | |
|
1077 | additionalInfo.Add(".1%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.001f).ToString()); | |
|
1078 |
additionalInfo.Add("1%% fps", MathUtils.Percentile(past_fps |
|
|
1079 |
additionalInfo.Add(" |
|
|
1078 | if ((past_fps.Count() > 5) && show_another_window) { | |
|
1079 | var past_fps_floats = past_fps.Skip(5).ToArray(); | |
|
1080 | Array.Sort(past_fps_floats); | |
|
1081 | additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps_floats, 0.0001f).ToString()); | |
|
1082 | additionalInfo.Add(".1%% fps", MathUtils.Percentile(past_fps_floats, 0.001f).ToString()); | |
|
1083 | additionalInfo.Add("1%% fps", MathUtils.Percentile(past_fps_floats, 0.01f).ToString()); | |
|
1084 | additionalInfo.Add("50%% fps", MathUtils.Percentile(past_fps_floats, 0.50f).ToString()); | |
|
1080 | 1085 | } |
|
1081 | 1086 | |
|
1082 | if (past_draw.Count() > 5) { | |
|
1083 |
var past_draw_floats = past_draw.Skip(5 |
|
|
1087 | if ((past_draw.Count() > 5) && show_another_window) { | |
|
1088 | var past_draw_floats = past_draw_millis.Skip(5).ToArray(); | |
|
1089 | Array.Sort(past_draw_floats); | |
|
1084 | 1090 | additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString()); |
|
1085 | 1091 | additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString()); |
|
1086 | 1092 | additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString()); |
You need to be logged in to leave comments.
Login now