Package com.reign.kat.lib.utils.stats
Class BotStats
java.lang.Object
com.reign.kat.lib.utils.stats.BotStats
Bot Statistics Monitor
Contains information about recent command executions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCommandExecutionStat
(Command command, long timeTaken, CommandParameters input) Log a command execution and its stats to the BotStats history.static void
addCommands
(Command... commands) Add multiple commands to be monitored.static void
addCommands
(Collection<Command> commands) Add a Collection of Command to be monitored and timed.static void
addToReport
(String key, Supplier<Float> func) Prints a nicely formatted table to the terminal of average execution times of all commands.Get the last 10 average execution time of all commands monitored.getAvgExecutionTimeFor
(Command... commands) Returns the average execution time for a list of commandsstatic HashMap<Command,
ArrayList<CommandExecution>> getCommandExecutionHistoryFor
(Command... commands) Returns a HashMap of CommandExecutions for each specified command the key being the Command, and the value being a CommandExecutionstatic void
-
Field Details
-
HISTORY_SIZE
public static final int HISTORY_SIZE- See Also:
-
-
Constructor Details
-
BotStats
-
-
Method Details
-
addToReport
-
addCommands
Add multiple commands to be monitored.- Parameters:
commands
- Commands to be monitored.
-
addCommands
Add a Collection of Command to be monitored and timed.- Parameters:
commands
- Commands to add to the monitoring system.
-
addCommandExecutionStat
public static void addCommandExecutionStat(Command command, long timeTaken, CommandParameters input) Log a command execution and its stats to the BotStats history.- Parameters:
command
- Command which was executed.timeTaken
- how long the command took to execute (ms).input
- The arguments passed to the command.
-
getCommandExecutionHistoryFor
public static HashMap<Command,ArrayList<CommandExecution>> getCommandExecutionHistoryFor(Command... commands) Returns a HashMap of CommandExecutions for each specified command the key being the Command, and the value being a CommandExecution- Parameters:
commands
- commands to fetch for.- Returns:
- HashMap of Command, CommandExecution
-
getAvgExecutionTimeFor
Returns the average execution time for a list of commands- Parameters:
commands
- Commands to retrieve the avg. execution time for.- Returns:
- Hashmap of commands and their execution times in ms.
-
getAvgExecutionTime
Get the last 10 average execution time of all commands monitored.- Returns:
- Hashmap of the previous 10 execution timings.
-
buildReport
Prints a nicely formatted table to the terminal of average execution times of all commands. -
reportToConsole
public static void reportToConsole()
-