Description:
Further tweaks to limit performance impact of timing calculation.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -57,6 +57,7 | |||||
|
57 |
|
57 | ||
|
58 | int frameRate = 0; |
|
58 | int frameRate = 0; |
|
59 | int frameCounter = 0; |
|
59 | int frameCounter = 0; |
|
|
60 | long totalFrameCounter = 0; //Will cover over a billion years at 60 fps | ||
|
60 | TimeSpan elapsedTime = TimeSpan.Zero; |
|
61 | TimeSpan elapsedTime = TimeSpan.Zero; |
|
61 | TimeSpan drawTime = TimeSpan.Zero; |
|
62 | TimeSpan drawTime = TimeSpan.Zero; |
|
62 | TimeSpan tileDrawTime = TimeSpan.Zero; |
|
63 | TimeSpan tileDrawTime = TimeSpan.Zero; |
@@ -69,9 +70,9 | |||||
|
69 | TimeSpan worldUpdateTime = TimeSpan.Zero; |
|
70 | TimeSpan worldUpdateTime = TimeSpan.Zero; |
|
70 | TimeSpan simulationUpdateTime = TimeSpan.Zero; |
|
71 | TimeSpan simulationUpdateTime = TimeSpan.Zero; |
|
71 |
|
72 | ||
|
72 |
|
|
73 | List<float> past_fps = new List<float>(100); |
|
73 | Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
74 | // Queue<TimeSpan> past_draw = new Queue<TimeSpan>(100); |
|
74 |
|
|
75 | List<float> past_draw_millis = new List<float>(100); |
|
75 | int tilesDrawn = 0; |
|
76 | int tilesDrawn = 0; |
|
76 |
|
77 | ||
|
77 | private static int width = 1280; |
|
78 | private static int width = 1280; |
@@ -680,6 +681,7 | |||||
|
680 | protected override void Draw(GameTime gameTime) |
|
681 | protected override void Draw(GameTime gameTime) |
|
681 | { |
|
682 | { |
|
682 | frameCounter++; |
|
683 | frameCounter++; |
|
|
684 | totalFrameCounter++; | ||
|
683 |
|
685 | ||
|
684 | string fps = string.Format("fps: {0}", frameRate); |
|
686 | string fps = string.Format("fps: {0}", frameRate); |
|
685 | bool has_tree = false; |
|
687 | bool has_tree = false; |
@@ -996,11 +998,14 | |||||
|
996 | stopWatch2 = new Stopwatch(); |
|
998 | stopWatch2 = new Stopwatch(); |
|
997 | stopWatch2.Start(); |
|
999 | stopWatch2.Start(); |
|
998 | //Calcs for debug window: |
|
1000 | //Calcs for debug window: |
|
999 | past_draw.Enqueue(this.drawTime); |
|
1001 | // past_draw.Enqueue(this.drawTime); |
|
1000 | past_draw_millis.Enqueue((float)this.drawTime.TotalMilliseconds); |
|
1002 | Logging.Spy(new {frame = this.frameCounter}); |
|
1001 | if ((this.frameCounter % 15) == 0) |
|
1003 | if (this.totalFrameCounter > 60 && ((this.frameCounter % 15) == 0)) |
|
1002 | { |
|
1004 | { |
|
1003 | past_fps.Enqueue(this.frameRate); |
|
1005 | past_draw_millis.Add((float)this.drawTime.TotalMilliseconds); |
|
|
1006 | past_draw_millis.Sort(); | ||
|
|
1007 | past_fps.Add(this.frameRate); | ||
|
|
1008 | past_fps.Sort(); | ||
|
1004 |
|
1009 | ||
|
1005 |
|
1010 | ||
|
1006 | /* |
|
1011 | /* |
@@ -1076,17 +1081,15 | |||||
|
1076 | additionalInfo.Add("Metadata entries", descriptions); |
|
1081 | additionalInfo.Add("Metadata entries", descriptions); |
|
1077 |
|
1082 | ||
|
1078 | if ((past_fps.Count() > 5) && show_another_window) { |
|
1083 | if ((past_fps.Count() > 5) && show_another_window) { |
|
1079 |
var past_fps_floats = past_fps. |
|
1084 | var past_fps_floats = past_fps.ToArray(); |
|
1080 | Array.Sort(past_fps_floats); |
|
||
|
1081 | additionalInfo.Add(".01%% fps", MathUtils.Percentile(past_fps_floats, 0.0001f).ToString()); |
|
1085 | 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()); |
|
1086 | 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()); |
|
1087 | 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()); |
|
1088 | additionalInfo.Add("50%% fps", MathUtils.Percentile(past_fps_floats, 0.50f).ToString()); |
|
1085 | } |
|
1089 | } |
|
1086 |
|
1090 | ||
|
1087 | if ((past_draw.Count() > 5) && show_another_window) { |
|
1091 | if ((past_draw_millis.Count() > 5) && show_another_window) { |
|
1088 |
var past_draw_floats = past_draw_millis. |
|
1092 | var past_draw_floats = past_draw_millis.ToArray(); |
|
1089 | Array.Sort(past_draw_floats); |
|
||
|
1090 | additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString()); |
|
1093 | additionalInfo.Add(".01%% draw", MathUtils.Percentile(past_draw_floats, 0.0001f).ToString()); |
|
1091 | additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString()); |
|
1094 | additionalInfo.Add(".1%% draw", MathUtils.Percentile(past_draw_floats, 0.001f).ToString()); |
|
1092 | additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString()); |
|
1095 | additionalInfo.Add("1%% draw", MathUtils.Percentile(past_draw_floats, 0.01f).ToString()); |
You need to be logged in to leave comments.
Login now