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 | using System.Collections.Generic; |
|
11 | using System.Collections.Generic; |
|
12 | using System.Linq; |
|
12 | using System.Linq; |
|
13 | using SpriteFontPlus; |
|
13 | using SpriteFontPlus; |
|
|
14 | using JM.LinqFaster; | ||
|
14 |
|
15 | ||
|
15 | using isometricparkfna; |
|
16 | using isometricparkfna; |
|
16 | using static isometricparkfna.CellMap; |
|
17 | using static isometricparkfna.CellMap; |
@@ -70,6 +71,7 | |||||
|
70 |
|
71 | ||
|
71 | Queue<float> past_fps = new Queue<float>(100); |
|
72 | Queue<float> past_fps = new Queue<float>(100); |
|
72 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
73 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
|
74 | Queue<float> past_draw_millis = new Queue<float>(100); | ||
|
73 | int tilesDrawn = 0; |
|
75 | int tilesDrawn = 0; |
|
74 |
|
76 | ||
|
75 | private static int width = 1280; |
|
77 | private static int width = 1280; |
@@ -995,6 +997,7 | |||||
|
995 | stopWatch2.Start(); |
|
997 | stopWatch2.Start(); |
|
996 | //Calcs for debug window: |
|
998 | //Calcs for debug window: |
|
997 | past_draw.Enqueue(this.drawTime); |
|
999 | past_draw.Enqueue(this.drawTime); |
|
|
1000 | past_draw_millis.Enqueue((float)this.drawTime.TotalMilliseconds); | ||
|
998 | if ((this.frameCounter % 15) == 0) |
|
1001 | if ((this.frameCounter % 15) == 0) |
|
999 | { |
|
1002 | { |
|
1000 | past_fps.Enqueue(this.frameRate); |
|
1003 | past_fps.Enqueue(this.frameRate); |
@@ -1072,15 +1075,18 | |||||
|
1072 | additionalInfo.Add("Dialog entries", entries); |
|
1075 | additionalInfo.Add("Dialog entries", entries); |
|
1073 | additionalInfo.Add("Metadata entries", descriptions); |
|
1076 | additionalInfo.Add("Metadata entries", descriptions); |
|
1074 |
|
1077 | ||
|
1075 | if (past_fps.Count() > 5) { |
|
1078 | if ((past_fps.Count() > 5) && show_another_window) { |
|
1076 | additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.0001f).ToString()); |
|
1079 | var past_fps_floats = past_fps.Skip(5).ToArray(); |
|
1077 | additionalInfo.Add(".1%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.001f).ToString()); |
|
1080 | Array.Sort(past_fps_floats); |
|
1078 |
additionalInfo.Add("1%% fps", MathUtils.Percentile(past_fps |
|
1081 | additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps_floats, 0.0001f).ToString()); |
|
1079 |
additionalInfo.Add(" |
|
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) { |
|
1087 | if ((past_draw.Count() > 5) && show_another_window) { |
|
1083 |
var past_draw_floats = past_draw.Skip(5 |
|
1088 | var past_draw_floats = past_draw_millis.Skip(5).ToArray(); |
|
|
1089 | Array.Sort(past_draw_floats); | ||
|
1084 | additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString()); |
|
1090 | additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString()); |
|
1085 | additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString()); |
|
1091 | additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString()); |
|
1086 | additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString()); |
|
1092 | additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString()); |
@@ -154,7 +154,7 | |||||
|
154 |
|
154 | ||
|
155 | public static float Percentile(float[] floats, float percentile) { |
|
155 | public static float Percentile(float[] floats, float percentile) { |
|
156 | if (floats.Length > 0) { |
|
156 | if (floats.Length > 0) { |
|
157 | Array.Sort(floats); |
|
157 | // Array.Sort(floats); |
|
158 | var raw_position = (floats.Length-1) * percentile; |
|
158 | var raw_position = (floats.Length-1) * percentile; |
|
159 |
|
159 | ||
|
160 | var lower_position = (int)raw_position; |
|
160 | var lower_position = (int)raw_position; |
You need to be logged in to leave comments.
Login now