summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/Events/EventManager.cs1
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs1
-rw-r--r--src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs4
-rw-r--r--src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs6
4 files changed, 11 insertions, 1 deletions
diff --git a/src/SMAPI/Framework/Events/EventManager.cs b/src/SMAPI/Framework/Events/EventManager.cs
index 9c65a6cc..19a4dff8 100644
--- a/src/SMAPI/Framework/Events/EventManager.cs
+++ b/src/SMAPI/Framework/Events/EventManager.cs
@@ -174,6 +174,7 @@ namespace StardewModdingAPI.Framework.Events
/// <summary>Construct an instance.</summary>
/// <param name="monitor">Writes messages to the log.</param>
/// <param name="modRegistry">The mod registry with which to identify mods.</param>
+ /// <param name="performanceCounterManager">The performance counter manager.</param>
public EventManager(IMonitor monitor, ModRegistry modRegistry, PerformanceCounterManager performanceCounterManager)
{
// create shortcut initializers
diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs
index bba94c35..dfdd7449 100644
--- a/src/SMAPI/Framework/Events/ManagedEvent.cs
+++ b/src/SMAPI/Framework/Events/ManagedEvent.cs
@@ -40,6 +40,7 @@ namespace StardewModdingAPI.Framework.Events
/// <param name="eventName">A human-readable name for the event.</param>
/// <param name="monitor">Writes messages to the log.</param>
/// <param name="modRegistry">The mod registry with which to identify mods.</param>
+ /// <param name="performanceCounterManager">The performance counter manager</param>
public ManagedEvent(string eventName, IMonitor monitor, ModRegistry modRegistry, PerformanceCounterManager performanceCounterManager)
{
this.EventName = eventName;
diff --git a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs
index b2ec4c90..33ddde2f 100644
--- a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs
+++ b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs
@@ -114,6 +114,10 @@ namespace StardewModdingAPI.Framework.PerformanceCounter
DateTime start = relativeTo.Value.Subtract(range);
var entries = this._counter.Where(x => (x.EventTime >= start) && (x.EventTime <= relativeTo));
+
+ if (!entries.Any())
+ return 0;
+
return entries.Average(x => x.ElapsedMilliseconds);
}
}
diff --git a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs
index d8f1f172..49720431 100644
--- a/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs
+++ b/src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs
@@ -20,6 +20,9 @@ namespace StardewModdingAPI.Framework.PerformanceCounter
/// <summary>The invocation stopwatch.</summary>
private readonly Stopwatch InvocationStopwatch = new Stopwatch();
+ /// <summary>Specifies if alerts should be paused.</summary>
+ public bool PauseAlerts { get; set; }
+
/// <summary>Constructs a performance counter manager.</summary>
/// <param name="monitor">The monitor for output logging.</param>
public PerformanceCounterManager(IMonitor monitor)
@@ -144,7 +147,8 @@ namespace StardewModdingAPI.Framework.PerformanceCounter
/// <param name="entry">The alert to add.</param>
public void AddAlert(AlertEntry entry)
{
- this.Alerts.Add(entry);
+ if (!this.PauseAlerts)
+ this.Alerts.Add(entry);
}
/// <summary>Initialized the default performance counter collections.</summary>