summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/PerformanceCounter
diff options
context:
space:
mode:
authorDrachenkaetzchen <felicia@drachenkatze.org>2020-01-15 17:43:41 +0100
committerDrachenkaetzchen <felicia@drachenkatze.org>2020-01-15 17:43:41 +0100
commitfce5814bcb150c4ff105a37dfcd57f397b117e48 (patch)
treec4515f7d4531932e433f7c735f78e3cc273cb818 /src/SMAPI/Framework/PerformanceCounter
parent1d58a525fa170a8e0de3de38477c501fb83f0b5a (diff)
downloadSMAPI-fce5814bcb150c4ff105a37dfcd57f397b117e48.tar.gz
SMAPI-fce5814bcb150c4ff105a37dfcd57f397b117e48.tar.bz2
SMAPI-fce5814bcb150c4ff105a37dfcd57f397b117e48.zip
Added documentation for all commands. Renamed the "monitor" command to "trigger". Method name refactoring to be more consistent.
Diffstat (limited to 'src/SMAPI/Framework/PerformanceCounter')
-rw-r--r--src/SMAPI/Framework/PerformanceCounter/PerformanceCounter.cs4
-rw-r--r--src/SMAPI/Framework/PerformanceCounter/PerformanceCounterManager.cs6
2 files changed, 9 insertions, 1 deletions
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>