java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler

public class SlimefunProfiler extends Object
The SlimefunProfiler works closely to the TickerTask and is responsible for monitoring that task. It collects timings data for any ticked Block and the corresponding SlimefunItem. This allows developers to identify laggy SlimefunItems or SlimefunAddons. But it also enables Server Admins to locate lag-inducing areas on the Server.
Author:
TheBusyBiscuit
See Also:
  • Constructor Details

    • SlimefunProfiler

      public SlimefunProfiler()
  • Method Details

    • kill

      public void kill()
      This method terminates the SlimefunProfiler. We need to call this method when the Server shuts down to prevent any of our Threads from being kept alive.
    • start

      public void start()
      This method starts the profiling, data from previous runs will be cleared.
    • newEntry

      public long newEntry()
      This method starts a new profiler entry.
      Returns:
      A timestamp, best fed back into closeEntry(Location, SlimefunItem, long)
    • scheduleEntries

      public void scheduleEntries(int amount)
      This method schedules a given amount of entries for the future. Be careful to closeEntry(Location, SlimefunItem, long) all of them again! No PerformanceSummary will be sent until all entries were closed. If the specified amount is negative, scheduled entries will be removed
      Parameters:
      amount - The amount of entries that should be scheduled. Can be negative
    • closeEntry

      public long closeEntry(@Nonnull Location l, @Nonnull SlimefunItem item, long timestamp)
      This method closes a previously started entry. Make sure to call newEntry() to get the timestamp in advance.
      Parameters:
      l - The Location of our Block
      item - The SlimefunItem at this Location
      timestamp - The timestamp marking the start of this entry, you can retrieve it using newEntry()
      Returns:
      The total timings of this entry
    • stop

      public void stop()
      This stops the profiling.
    • requestSummary

      public void requestSummary(@Nonnull PerformanceInspector inspector)
      This method requests a summary for the given PerformanceInspector. The summary will be sent upon the next available moment in time.
      Parameters:
      inspector - The PerformanceInspector who shall receive this summary.
    • getByItem

      @Nonnull protected Map<String,Long> getByItem()
    • getByPlugin

      @Nonnull protected Map<String,Long> getByPlugin()
    • getByChunk

      @Nonnull protected Map<String,Long> getByChunk()
    • getBlocksInChunk

      protected int getBlocksInChunk(@Nonnull String chunk)
    • getBlocksOfId

      protected int getBlocksOfId(@Nonnull String id)
    • getBlocksFromPlugin

      protected int getBlocksFromPlugin(@Nonnull String pluginName)
    • getPercentageOfTick

      protected float getPercentageOfTick()
    • getPerformance

      @Nonnull public PerformanceRating getPerformance()
      This method returns the current PerformanceRating.
      Returns:
      The current performance grade
    • getTime

      @Nonnull public String getTime()
    • getTickRate

      public int getTickRate()
    • hasTimings

      public boolean hasTimings(@Nonnull Block b)
      This method checks whether the SlimefunProfiler has collected timings on the given Block
      Parameters:
      b - The Block
      Returns:
      Whether timings of this Block have been collected
    • getTime

      public String getTime(@Nonnull Block b)
    • getTime

      public String getTime(@Nonnull Chunk chunk)
    • getTime

      public String getTime(@Nonnull SlimefunItem item)
    • getAndResetAverageTimings

      public long getAndResetAverageTimings()
      Get and reset the average millisecond timing for this SlimefunProfiler.
      Returns:
      The average millisecond timing for this SlimefunProfiler.
    • getAndResetAverageNanosecondTimings

      public double getAndResetAverageNanosecondTimings()
      Get and reset the average nanosecond timing for this SlimefunProfiler.
      Returns:
      The average nanosecond timing for this SlimefunProfiler.
    • getAverageTimingsPerMachine

      public double getAverageTimingsPerMachine()
      Get and reset the average millisecond timing for each machine.
      Returns:
      The average millisecond timing for each machine.