Class Timings

java.lang.Object
co.aikar.timings.Timings

public final class Timings extends Object
  • Field Details

    • NULL_HANDLER

      public static final Timing NULL_HANDLER
  • Method Details

    • of

      @NotNull public static @NotNull Timing of(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name)
      Returns a Timing for a plugin corresponding to a name.
      Parameters:
      plugin - Plugin to own the Timing
      name - Name of Timing
      Returns:
      Handler
    • of

      @NotNull public static @NotNull Timing of(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, @Nullable @Nullable Timing groupHandler)

      Returns a handler that has a groupHandler timer handler. Parent timers should not have their start/stop methods called directly, as the children will call it for you.

      Parent Timers are used to group multiple subsections together and get a summary of them combined Parent Handler can not be changed after first call
      Parameters:
      plugin - Plugin to own the Timing
      name - Name of Timing
      groupHandler - Parent handler to mirror .start/stop calls to
      Returns:
      Timing Handler
    • ofStart

      @NotNull public static @NotNull Timing ofStart(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name)
      Returns a Timing object after starting it, useful for Java7 try-with-resources. try (Timing ignored = Timings.ofStart(plugin, someName)) { // timed section }
      Parameters:
      plugin - Plugin to own the Timing
      name - Name of Timing
      Returns:
      Timing Handler
    • ofStart

      @NotNull public static @NotNull Timing ofStart(@NotNull @NotNull Plugin plugin, @NotNull @NotNull String name, @Nullable @Nullable Timing groupHandler)
      Returns a Timing object after starting it, useful for Java7 try-with-resources. try (Timing ignored = Timings.ofStart(plugin, someName, groupHandler)) { // timed section }
      Parameters:
      plugin - Plugin to own the Timing
      name - Name of Timing
      groupHandler - Parent handler to mirror .start/stop calls to
      Returns:
      Timing Handler
    • isTimingsEnabled

      public static boolean isTimingsEnabled()
      Gets whether or not the Spigot Timings system is enabled
      Returns:
      Enabled or not
    • setTimingsEnabled

      public static void setTimingsEnabled(boolean enabled)

      Sets whether or not the Spigot Timings system should be enabled

      Calling this will reset timing data.
      Parameters:
      enabled - Should timings be reported
    • isVerboseTimingsEnabled

      public static boolean isVerboseTimingsEnabled()

      Sets whether or not the Timings should monitor at Verbose level.

      When Verbose is disabled, high-frequency timings will not be available.

      Returns:
      Enabled or not
    • setVerboseTimingsEnabled

      public static void setVerboseTimingsEnabled(boolean enabled)

      Sets whether or not the Timings should monitor at Verbose level.

      When Verbose is disabled, high-frequency timings will not be available. Calling this will reset timing data.
      Parameters:
      enabled - Should high-frequency timings be reported
    • getHistoryInterval

      public static int getHistoryInterval()

      Gets the interval between Timing History report generation.

      Defaults to 5 minutes (6000 ticks)
      Returns:
      Interval in ticks
    • setHistoryInterval

      public static void setHistoryInterval(int interval)

      Sets the interval between Timing History report generations.

      Defaults to 5 minutes (6000 ticks)

      This will recheck your history length, so lowering this value will lower your history length if you need more than 60 history windows.
      Parameters:
      interval - Interval in ticks
    • getHistoryLength

      public static int getHistoryLength()
      Gets how long in ticks Timings history is kept for the server. Defaults to 1 hour (72000 ticks)
      Returns:
      Duration in Ticks
    • setHistoryLength

      public static void setHistoryLength(int length)
      Sets how long Timing History reports are kept for the server. Defaults to 1 hours(72000 ticks) This value is capped at a maximum of getHistoryInterval() * MAX_HISTORY_FRAMES (12) Will not reset Timing Data but may truncate old history if the new length is less than old length.
      Parameters:
      length - Duration in ticks
    • reset

      public static void reset()
      Resets all Timing Data
    • generateReport

      public static void generateReport(@Nullable @Nullable CommandSender sender)
      Generates a report and sends it to the specified command sender. If sender is null, ConsoleCommandSender will be used.
      Parameters:
      sender - The sender to send to, or null to use the ConsoleCommandSender
    • generateReport

      public static void generateReport(@NotNull @NotNull TimingsReportListener sender)
      Generates a report and sends it to the specified listener. Use with BufferedCommandSender to get full response when done!
      Parameters:
      sender - The listener to send responses too.