Class EventProfiler

java.lang.Object
dev.despical.whackme.api.EventProfiler

public final class EventProfiler extends Object
Collects listener execution timings for events dispatched by EventManager.

Measurements are aggregated per concrete event class using thread-safe counters. In verbose mode each dispatch is also written to the plugin log; otherwise data remains available for the on-demand timings report.

API Note: Profiling measures the complete Bukkit dispatch call, including all registered listeners. It does not identify the execution time of an individual listener.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a profiler and loads its enabled and verbose flags.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether event measurements are currently collected.
    boolean
    Returns whether every measured dispatch is logged immediately.
    void
    record(org.bukkit.event.Event event, long durationNanos)
    Records one completed event dispatch.
    void
    Reloads profiler flags from the current configuration options.
    void
    sendReport(org.bukkit.command.CommandSender sender)
    Sends a report ordered by total execution time to the supplied sender.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventProfiler

      public EventProfiler(WhackMe plugin)
      Creates a profiler and loads its enabled and verbose flags.
      Parameters:
      plugin - active Whack Me plugin instance
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Returns whether event measurements are currently collected.
      Returns:
      true when profiling is enabled
    • isVerbose

      public boolean isVerbose()
      Returns whether every measured dispatch is logged immediately.
      Returns:
      true when verbose profiling is enabled
    • reload

      public void reload()
      Reloads profiler flags from the current configuration options. Existing measurements are retained.
    • record

      public void record(org.bukkit.event.Event event, long durationNanos)
      Records one completed event dispatch.
      Parameters:
      event - dispatched event
      durationNanos - complete dispatch duration in nanoseconds
    • sendReport

      public void sendReport(org.bukkit.command.CommandSender sender)
      Sends a report ordered by total execution time to the supplied sender. A configuration hint is sent instead when profiling is disabled.
      Parameters:
      sender - report recipient