diff options
author | Drachenkaetzchen <felicia@drachenkatze.org> | 2020-01-21 12:20:06 +0100 |
---|---|---|
committer | Drachenkaetzchen <felicia@drachenkatze.org> | 2020-01-21 12:20:06 +0100 |
commit | 1b905205a3073c56e29c46b5e57c4a9cb2ca5832 (patch) | |
tree | 677358e51b8b3a8ba37ffd480f4a12778a2cafd9 /src/SMAPI.Mods.ConsoleCommands/Framework | |
parent | 84973ce5727ad20fe8b8ba4f89e59c8b754f799e (diff) | |
download | SMAPI-1b905205a3073c56e29c46b5e57c4a9cb2ca5832.tar.gz SMAPI-1b905205a3073c56e29c46b5e57c4a9cb2ca5832.tar.bz2 SMAPI-1b905205a3073c56e29c46b5e57c4a9cb2ca5832.zip |
Added commands to enable and disable performance counters. Peak is now using the default interval
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework')
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/PerformanceCounterCommand.cs | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/PerformanceCounterCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/PerformanceCounterCommand.cs index d49fc537..2260296b 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/PerformanceCounterCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Other/PerformanceCounterCommand.cs @@ -17,6 +17,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other {SubCommand.Detail, new[] {"detail", "d"}}, {SubCommand.Reset, new[] {"reset", "r"}}, {SubCommand.Trigger, new[] {"trigger"}}, + {SubCommand.Enable, new[] {"enable"}}, + {SubCommand.Disable, new[] {"disable"}}, {SubCommand.Examples, new[] {"examples"}}, {SubCommand.Concepts, new[] {"concepts"}}, {SubCommand.Help, new[] {"help"}}, @@ -29,6 +31,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other Detail, Reset, Trigger, + Enable, + Disable, Examples, Help, Concepts, @@ -69,6 +73,14 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other case SubCommand.Concepts: this.OutputHelp(monitor, SubCommand.Concepts); break; + case SubCommand.Enable: + SCore.PerformanceCounterManager.EnableTracking = true; + monitor.Log("Performance counter tracking is now enabled", LogLevel.Info); + break; + case SubCommand.Disable: + SCore.PerformanceCounterManager.EnableTracking = false; + monitor.Log("Performance counter tracking is now disabled", LogLevel.Info); + break; case SubCommand.Help: if (args.TryGet(1, "command", out string commandString)) this.OutputHelp(monitor, this.ParseCommandString(commandString)); @@ -118,20 +130,20 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other StringBuilder sb = new StringBuilder(); - TimeSpan peakSpan = TimeSpan.FromSeconds(60); + TimeSpan interval = TimeSpan.FromSeconds(60); - sb.AppendLine("Summary:"); + sb.AppendLine($"Summary over the last {interval.TotalSeconds} seconds:"); sb.AppendLine(this.GetTableString( data: data, - header: new[] {"Collection", "Avg Calls/s", "Avg Exec Time (Game)", "Avg Exec Time (Mods)", "Avg Exec Time (Game+Mods)", "Peak Exec Time (60s)"}, + header: new[] {"Collection", "Avg Calls/s", "Avg Exec Time (Game)", "Avg Exec Time (Mods)", "Avg Exec Time (Game+Mods)", "Peak Exec Time"}, getRow: item => new[] { item.Name, item.GetAverageCallsPerSecond().ToString(), - this.FormatMilliseconds(item.GetGameAverageExecutionTime(), threshold), - this.FormatMilliseconds(item.GetModsAverageExecutionTime(), threshold), - this.FormatMilliseconds(item.GetAverageExecutionTime(), threshold), - this.FormatMilliseconds(item.GetPeakExecutionTime(peakSpan), threshold) + this.FormatMilliseconds(item.GetGameAverageExecutionTime(interval), threshold), + this.FormatMilliseconds(item.GetModsAverageExecutionTime(interval), threshold), + this.FormatMilliseconds(item.GetAverageExecutionTime(interval), threshold), + this.FormatMilliseconds(item.GetPeakExecutionTime(interval), threshold) }, true )); @@ -662,6 +674,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other sb.AppendLine(" detail|d Shows performance counter information for a given collection"); sb.AppendLine(" reset|r Resets the performance counters"); sb.AppendLine(" trigger Configures alert triggers"); + sb.AppendLine(" enable Enables performance counter recording"); + sb.AppendLine(" disable Disables performance counter recording"); sb.AppendLine(" examples Displays various examples"); sb.AppendLine(" concepts Displays an explanation of the performance counter concepts"); sb.AppendLine(" help Displays verbose help for the available commands"); |