Package net.minestom.server.benchmark
Class BenchmarkManager
java.lang.Object
net.minestom.server.benchmark.BenchmarkManager
public final class BenchmarkManager
extends java.lang.Object
Small monitoring tools that can be used to check the current memory usage and Minestom threads CPU usage.
Needs to be enabled with enable(UpdateOption)
. Memory can then be accessed with getUsedMemory()
and the CPUs usage with getResultMap()
or getCpuMonitoringMessage()
.
Be aware that this is not the most accurate method, you should use a proper java profiler depending on your needs.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.management.ThreadMXBean
THREAD_MX_BEAN
-
Constructor Summary
Constructors Constructor Description BenchmarkManager()
-
Method Summary
Modifier and Type Method Description void
addThreadMonitor(java.lang.String threadName)
void
disable()
void
enable(UpdateOption updateOption)
java.lang.String
getCpuMonitoringMessage()
java.util.Map<java.lang.String,ThreadResult>
getResultMap()
long
getUsedMemory()
Gets the heap memory used by the server in bytes.
-
Field Details
-
THREAD_MX_BEAN
public static final java.lang.management.ThreadMXBean THREAD_MX_BEAN
-
-
Constructor Details
-
BenchmarkManager
public BenchmarkManager()
-
-
Method Details
-
enable
-
disable
public void disable() -
addThreadMonitor
public void addThreadMonitor(@NotNull java.lang.String threadName) -
getUsedMemory
public long getUsedMemory()Gets the heap memory used by the server in bytes.- Returns:
- the memory used by the server
-
getResultMap
-
getCpuMonitoringMessage
public java.lang.String getCpuMonitoringMessage()
-