diff options
author | Drachenkaetzchen <felicia@drachenkatze.org> | 2020-01-10 14:16:00 +0100 |
---|---|---|
committer | Drachenkaetzchen <felicia@drachenkatze.org> | 2020-01-10 14:16:00 +0100 |
commit | 8a77373b18dbda77f268e8e7f772e950da60829f (patch) | |
tree | 60ac9d8ef01a5f681e73f146d33369a9fe4ef71b /src/SMAPI/Framework | |
parent | 47f626cc99c93a28b2d6867ed6cc717b39ec062c (diff) | |
download | SMAPI-8a77373b18dbda77f268e8e7f772e950da60829f.tar.gz SMAPI-8a77373b18dbda77f268e8e7f772e950da60829f.tar.bz2 SMAPI-8a77373b18dbda77f268e8e7f772e950da60829f.zip |
Added reset functionality
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs | 6 | ||||
-rw-r--r-- | src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs | 16 | ||||
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 8 |
3 files changed, 28 insertions, 2 deletions
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<PerformanceCounterEntry>(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<EventPerformanceCounterCategory>() diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 74a256fe..d1dba9ea 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -498,8 +498,9 @@ namespace StardewModdingAPI.Framework "Usage: performance_counters [name] [threshold]\n"+ "Shows detailed performance counters for a specific event\n"+ "- name: The (partial) name of the event\n"+ - "- threshold: The minimum avg execution time (ms) of the event\n"+ - "", this.HandleCommand); + "- threshold: The minimum avg execution time (ms) of the event\n\n"+ + "Usage: performance_counters reset\n"+ + "Resets all performance counters\n", this.HandleCommand); this.GameInstance.CommandManager.Add(null, "pc", "Alias for performance_counters", this.HandleCommand); // start handling command line input @@ -1393,6 +1394,9 @@ namespace StardewModdingAPI.Framework } } break; + case "reset": + this.PerformanceCounterManager.Reset(); + return; default: showSummary = false; filterByName = arguments[0]; |