From a179466e6b2800846bd425e2fe61de80d52d77bd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Jan 2021 00:44:24 -0500 Subject: remove experimental performance counters Unfortunately this impacted SMAPI's memory usage and the data was often misinterpreted by players. --- src/SMAPI/Framework/Events/ManagedEvent.cs | 44 ++++++++---------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'src/SMAPI/Framework/Events/ManagedEvent.cs') diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs index f2dfb2ab..2204966c 100644 --- a/src/SMAPI/Framework/Events/ManagedEvent.cs +++ b/src/SMAPI/Framework/Events/ManagedEvent.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using StardewModdingAPI.Events; -using StardewModdingAPI.Framework.PerformanceMonitoring; namespace StardewModdingAPI.Framework.Events { @@ -17,9 +16,6 @@ namespace StardewModdingAPI.Framework.Events /// The mod registry with which to identify mods. protected readonly ModRegistry ModRegistry; - /// Tracks performance metrics. - private readonly PerformanceMonitor PerformanceMonitor; - /// The underlying event handlers. private readonly List> Handlers = new List>(); @@ -49,13 +45,11 @@ namespace StardewModdingAPI.Framework.Events /// Construct an instance. /// A human-readable name for the event. /// The mod registry with which to identify mods. - /// Tracks performance metrics. /// Whether the event is typically called at least once per second. - public ManagedEvent(string eventName, ModRegistry modRegistry, PerformanceMonitor performanceMonitor, bool isPerformanceCritical = false) + public ManagedEvent(string eventName, ModRegistry modRegistry, bool isPerformanceCritical = false) { this.EventName = eventName; this.ModRegistry = modRegistry; - this.PerformanceMonitor = performanceMonitor; this.IsPerformanceCritical = isPerformanceCritical; } @@ -126,40 +120,26 @@ namespace StardewModdingAPI.Framework.Events } // raise event - this.PerformanceMonitor.Track(this.EventName, () => + foreach (ManagedEventHandler handler in handlers) { - foreach (ManagedEventHandler handler in handlers) - { - if (match != null && !match(handler.SourceMod)) - continue; + if (match != null && !match(handler.SourceMod)) + continue; - try - { - this.PerformanceMonitor.Track(this.EventName, this.GetModNameForPerformanceCounters(handler), () => handler.Handler.Invoke(null, args)); - } - catch (Exception ex) - { - this.LogError(handler, ex); - } + try + { + handler.Handler.Invoke(null, args); + } + catch (Exception ex) + { + this.LogError(handler, ex); } - }); + } } /********* ** Private methods *********/ - /// Get the mod name for a given event handler to display in performance monitoring reports. - /// The event handler. - private string GetModNameForPerformanceCounters(ManagedEventHandler handler) - { - IModMetadata mod = handler.SourceMod; - - return mod.HasManifest() - ? mod.Manifest.UniqueID - : mod.DisplayName; - } - /// Log an exception from an event handler. /// The event handler instance. /// The exception that was raised. -- cgit