Interface ThreadProfiler

All Known Implementing Classes:
BaselineThreadMXBeanThreadProfiler, NullThreadProfiler, SunThreadMXBeanThreadProfiler, ThreadMXBeanThreadProfiler

public interface ThreadProfiler
Interface for thread profiling utilities which may be platform or JVM dependent.
  • Field Details

    • CPU_PROFILING_ENABLED

      static final boolean CPU_PROFILING_ENABLED
    • MEMORY_PROFILING_ENABLED

      static final boolean MEMORY_PROFILING_ENABLED
    • DEFAULT

      static final ThreadProfiler DEFAULT
      Default instance for almost all usage.
  • Method Details

    • memoryProfilingAvailable

      boolean memoryProfilingAvailable()
      Check if memory profiling (e.g. getCurrentThreadAllocatedBytes()) is available (supported and enabled).
      Returns:
      Whether memory profiling is available.
    • getCurrentThreadAllocatedBytes

      long getCurrentThreadAllocatedBytes()
      Get the approximate number of total bytes allocated by the current thread.
      Returns:
      The approximate number of total bytes allocated by the current thread, or QueryConstants.NULL_LONG if unavailable.
    • cpuProfilingAvailable

      boolean cpuProfilingAvailable()
      Check if CPU profiling (e.g. getCurrentThreadCpuTime() and getCurrentThreadUserTime()) is available (supported and enabled).
      Returns:
      Whether CPU profiling is available.
    • getCurrentThreadCpuTime

      long getCurrentThreadCpuTime()
      Get the approximate number of total nanoseconds the current thread has executed (in system or user mode) since CPU time measurement started.
      Returns:
      The approximate number of total nanoseconds the current thread has executed, or QueryConstants.NULL_LONG if unavailable.
    • getCurrentThreadUserTime

      long getCurrentThreadUserTime()
      Get the approximate number of total nanoseconds the current thread has executed (in user mode) since CPU time measurement started.
      Returns:
      The approximate number of total nanoseconds the current thread has executed in user mode, or QueryConstants.NULL_LONG if unavailable.
    • make

      static ThreadProfiler make()
      Make a new ThreadProfiler for this JVM. The result may not support all measurements, if there's no suitable implementation available.
      Returns:
      A new ThreadProfiler for this JVM.