Class SlimefunProfiler
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
closeEntry
(Location l, SlimefunItem item, long timestamp) This method closes a previously started entry.double
Get and reset the average nanosecond timing for thisSlimefunProfiler
.long
Get and reset the average millisecond timing for thisSlimefunProfiler
.double
Get and reset the average millisecond timing for each machine.protected int
getBlocksFromPlugin
(String pluginName) protected int
getBlocksInChunk
(String chunk) protected int
getBlocksOfId
(String id) protected float
This method returns the currentPerformanceRating
.int
getTime()
getTime
(SlimefunItem item) boolean
hasTimings
(Block b) This method checks whether theSlimefunProfiler
has collected timings on the givenBlock
void
kill()
This method terminates theSlimefunProfiler
.long
newEntry()
This method starts a new profiler entry.void
requestSummary
(PerformanceInspector inspector) This method requests a summary for the givenPerformanceInspector
.void
scheduleEntries
(int amount) This method schedules a given amount of entries for the future.void
start()
This method starts the profiling, data from previous runs will be cleared.void
stop()
This stops the profiling.
-
Constructor Details
-
SlimefunProfiler
public SlimefunProfiler()
-
-
Method Details
-
kill
public void kill()This method terminates theSlimefunProfiler
. We need to call this method when theServer
shuts down to prevent any of ourThreads
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 tocloseEntry(Location, SlimefunItem, long)
all of them again! NoPerformanceSummary
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
This method closes a previously started entry. Make sure to callnewEntry()
to get the timestamp in advance.- Parameters:
l
- TheLocation
of ourBlock
item
- TheSlimefunItem
at thisLocation
timestamp
- The timestamp marking the start of this entry, you can retrieve it usingnewEntry()
- Returns:
- The total timings of this entry
-
stop
public void stop()This stops the profiling. -
requestSummary
This method requests a summary for the givenPerformanceInspector
. The summary will be sent upon the next available moment in time.- Parameters:
inspector
- ThePerformanceInspector
who shall receive this summary.
-
getByItem
-
getByPlugin
-
getByChunk
-
getBlocksInChunk
-
getBlocksOfId
-
getBlocksFromPlugin
-
getPercentageOfTick
protected float getPercentageOfTick() -
getPerformance
This method returns the currentPerformanceRating
.- Returns:
- The current performance grade
-
getTime
-
getTickRate
public int getTickRate() -
hasTimings
This method checks whether theSlimefunProfiler
has collected timings on the givenBlock
-
getTime
-
getTime
-
getTime
-
getAndResetAverageTimings
public long getAndResetAverageTimings()Get and reset the average millisecond timing for thisSlimefunProfiler
.- Returns:
- The average millisecond timing for this
SlimefunProfiler
.
-
getAndResetAverageNanosecondTimings
public double getAndResetAverageNanosecondTimings()Get and reset the average nanosecond timing for thisSlimefunProfiler
.- 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.
-