Class BotStats

java.lang.Object
com.reign.kat.lib.utils.stats.BotStats

public class BotStats extends Object
Bot Statistics Monitor Contains information about recent command executions.
  • Field Details

  • Constructor Details

    • BotStats

      public BotStats(Command... commands)
  • Method Details

    • addToReport

      public static void addToReport(String key, Supplier<Float> func)
    • addCommands

      public static void addCommands(Command... commands)
      Add multiple commands to be monitored.
      Parameters:
      commands - Commands to be monitored.
    • addCommands

      public static void addCommands(Collection<Command> commands)
      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

      public static HashMap<Command,Float> getAvgExecutionTimeFor(Command... commands)
      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

      public static HashMap<Command,Float> getAvgExecutionTime()
      Get the last 10 average execution time of all commands monitored.
      Returns:
      Hashmap of the previous 10 execution timings.
    • buildReport

      public static Iterator<String> buildReport()
      Prints a nicely formatted table to the terminal of average execution times of all commands.
    • reportToConsole

      public static void reportToConsole()