diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index bff7eb4511..3f5c8ddfa3 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -602,7 +602,10 @@ namespace OpenRA if (orderManager.LastTickTime.ShouldAdvance(tick)) { - using (new PerfSample("tick_time")) + if (orderManager.GameStarted && orderManager.LocalFrameNumber == 0) + PerfHistory.Reset(); // Remove history that occurred whilst the new game was loading. + + using (var sample = new PerfSample("tick_time")) { orderManager.LastTickTime.AdvanceTickTime(tick); @@ -611,7 +614,11 @@ namespace OpenRA Sync.RunUnsynced(world, orderManager.TickImmediate); if (world == null) + { + if (orderManager.GameStarted) + PerfHistory.Reset(); // Remove old history when a new game starts. return; + } if (orderManager.TryTick()) { diff --git a/OpenRA.Game/Support/PerfHistory.cs b/OpenRA.Game/Support/PerfHistory.cs index 0d6a774e69..13731a8105 100644 --- a/OpenRA.Game/Support/PerfHistory.cs +++ b/OpenRA.Game/Support/PerfHistory.cs @@ -47,5 +47,11 @@ namespace OpenRA.Support if (item.HasNormalTick) item.Tick(); } + + public static void Reset() + { + foreach (var item in Items.Values) + item.ResetSamples(); + } } } diff --git a/OpenRA.Game/Support/PerfItem.cs b/OpenRA.Game/Support/PerfItem.cs index 4fb933ed57..c88a7d055c 100644 --- a/OpenRA.Game/Support/PerfItem.cs +++ b/OpenRA.Game/Support/PerfItem.cs @@ -72,5 +72,12 @@ namespace OpenRA.Support return samples[n]; } } + + public void ResetSamples() + { + head = 1; + tail = 0; + Val = 0.0; + } } }