Class Profiler

java.lang.Object
org.apache.jackrabbit.oak.commons.Profiler
All Implemented Interfaces:
Runnable

public class Profiler extends Object implements Runnable
A simple CPU profiling tool similar to java -Xrunhprof. It can be used in-process (to profile the current application) or as a standalone program (to profile a different process, or files containing full thread dumps).
  • Field Details

    • interval

      public int interval
    • depth

      public int depth
    • paused

      public boolean paused
    • sumClasses

      public boolean sumClasses
    • sumMethods

      public boolean sumMethods
  • Constructor Details

    • Profiler

      public Profiler()
  • Method Details

    • premain

      public static void premain(String agentArgs, Instrumentation inst)
      This method is called when the agent is installed.
      Parameters:
      agentArgs - the agent arguments
      inst - the instrumentation object
    • getInstrumentation

      public static Instrumentation getInstrumentation()
      Get the instrumentation object if started as an agent.
      Returns:
      the instrumentation, or null
    • main

      public static void main(String... args)
      Run the command line version of the profiler. The JDK (jps and jstack) need to be in the path.
      Parameters:
      args - the process id of the process - if not set the java processes are listed
    • startCollecting

      public Profiler startCollecting()
      Start collecting profiling data.
      Returns:
      this
    • stopCollecting

      public Profiler stopCollecting()
      Stop collecting.
      Returns:
      this
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • getTop

      public String getTop(int count)
      Get the top stack traces.
      Parameters:
      count - the maximum number of stack traces
      Returns:
      the stack traces.