From 8a77373b18dbda77f268e8e7f772e950da60829f Mon Sep 17 00:00:00 2001 From: Drachenkaetzchen Date: Fri, 10 Jan 2020 14:16:00 +0100 Subject: Added reset functionality --- .../Framework/PerformanceCounter/PerformanceCounter.cs | 6 ++++++ .../PerformanceCounter/PerformanceCounterManager.cs | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'src/SMAPI/Framework/PerformanceCounter') diff --git a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs index 04e0f5f5..0b0275b7 100644 --- a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs +++ b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs @@ -25,6 +25,12 @@ namespace StardewModdingAPI.Framework.PerformanceCounter this._counter = new CircularBuffer(PerformanceCounter.MAX_ENTRIES); } + public void Reset() + { + this._counter.Clear(); + this.PeakPerformanceCounterEntry = null; + } + public int GetAverageCallsPerSecond() { var x = this._counter.GroupBy( diff --git a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs index e2200e74..ae7258e2 100644 --- a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs +++ b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs @@ -16,6 +16,22 @@ namespace StardewModdingAPI.Framework.PerformanceCounter this.InitializePerformanceCounterEvents(); } + public void Reset() + { + foreach (var performanceCounter in this.PerformanceCounterEvents) + { + this.ResetCategory(performanceCounter); + } + } + + public void ResetCategory(EventPerformanceCounterCategory category) + { + foreach (var eventPerformanceCounter in category.Event.PerformanceCounters) + { + eventPerformanceCounter.Value.Reset(); + } + } + private void InitializePerformanceCounterEvents() { this.PerformanceCounterEvents = new HashSet() -- cgit