Description:
Show percentile timings and fps.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r518:577cf7b8675b -

@@ -63,6 +63,7
63 TimeSpan updateTime = TimeSpan.Zero;
63 TimeSpan updateTime = TimeSpan.Zero;
64
64
65 Queue<float> past_fps = new Queue<float>(100);
65 Queue<float> past_fps = new Queue<float>(100);
66 Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100);
66 int tilesDrawn = 0;
67 int tilesDrawn = 0;
67
68
68 private static int width = 1280;
69 private static int width = 1280;
@@ -866,10 +867,12
866
867
867 #region debug_window
868 #region debug_window
868 //Calcs for debug window:
869 //Calcs for debug window:
870 past_draw.Enqueue(this.drawTime);
869 if ((this.frameCounter % 15) == 0)
871 if ((this.frameCounter % 15) == 0)
870 {
872 {
871 past_fps.Enqueue(this.frameRate);
873 past_fps.Enqueue(this.frameRate);
872
874
875
873 /*
876 /*
874 if (this.frameRate > 60.0)
877 if (this.frameRate > 60.0)
875 {
878 {
@@ -937,6 +940,24
937 additionalInfo.Add("Dialog entries", entries);
940 additionalInfo.Add("Dialog entries", entries);
938 additionalInfo.Add("Metadata entries", descriptions);
941 additionalInfo.Add("Metadata entries", descriptions);
939
942
943 if (past_fps.Count() > 5) {
944 additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.0001f).ToString());
945 additionalInfo.Add(".1%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.001f).ToString());
946 additionalInfo.Add("1%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.01f).ToString());
947 additionalInfo.Add("50%% fps", MathUtils.Percentile(past_fps.Skip(5).ToArray(), 0.50f).ToString());
948 }
949
950 if (past_draw.Count() > 5) {
951 var past_draw_floats = past_draw.Skip(5).Select(ts => ts.TotalMilliseconds).ToArray();
952 additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString());
953 additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString());
954 additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString());
955 additionalInfo.Add("50%% draw", MathUtils.Percentile(past_draw_floats, 0.50f).ToString());
956 additionalInfo.Add("99%% draw", MathUtils.Percentile(past_draw_floats, 0.99f).ToString());
957 additionalInfo.Add("99.9%% draw", MathUtils.Percentile(past_draw_floats, 0.999f).ToString());
958 additionalInfo.Add("99.99%% draw", MathUtils.Percentile(past_draw_floats, 0.9999f).ToString());
959 }
960
940 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
961 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
941
962
942 _imGuiRenderer.AfterLayout();
963 _imGuiRenderer.AfterLayout();
@@ -1,6 +1,15
1 using System;
1 using System;
2 using JM.LinqFaster;
2 namespace isometricparkfna
3 namespace isometricparkfna
3 {
4 {
5 public class EmptyArrayException : Exception {
6 public EmptyArrayException() {
7 }
8
9 public EmptyArrayException(string message) : base(message) {
10 }
11
12 }
4 public class MathUtils
13 public class MathUtils
5 {
14 {
6 public MathUtils()
15 public MathUtils()
@@ -126,5 +135,39
126
135
127 return integers[index];
136 return integers[index];
128 }
137 }
138
139 public static float Percentile(float[] floats, float percentile) {
140 if (floats.Length > 0) {
141 Array.Sort(floats);
142 var raw_position = (floats.Length-1) * percentile;
143
144 var lower_position = (int)raw_position;
145 var higher_position = Math.Min((int)(raw_position+1), floats.Length-1);
146
147 var remainder = (raw_position % 1);
148
149 return (floats[lower_position] * (1-remainder)) + (floats[higher_position] * remainder);
150 }
151 else {
152 throw new EmptyArrayException("Array must not be empty");
153 }
154 }
155
156 public static double Percentile(double[] doubles, double percentile) {
157 if (doubles.Length > 0) {
158 Array.Sort(doubles);
159 var raw_position = (doubles.Length-1) * percentile;
160
161 var lower_position = (int)raw_position;
162 var higher_position = Math.Min((int)raw_position + 1, doubles.Length -1);
163
164 var remainder = (raw_position % 1);
165
166 return (doubles[lower_position] * (1-remainder)) + (doubles[higher_position] * remainder);
167 }
168 else {
169 throw new EmptyArrayException("Array must not be empty");
170 }
171 }
129 }
172 }
130 }
173 }
You need to be logged in to leave comments. Login now