Class Profiler
- java.lang.Object
-
- org.apache.jackrabbit.oak.commons.Profiler
-
- All Implemented Interfaces:
java.lang.Runnable
public class Profiler extends java.lang.Object implements java.lang.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 Summary
Fields Modifier and Type Field Description int
depth
int
interval
boolean
paused
boolean
sumClasses
boolean
sumMethods
-
Constructor Summary
Constructors Constructor Description Profiler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.instrument.Instrumentation
getInstrumentation()
Get the instrumentation object if started as an agent.java.lang.String
getTop(int count)
Get the top stack traces.static void
main(java.lang.String... args)
Run the command line version of the profiler.static void
premain(java.lang.String agentArgs, java.lang.instrument.Instrumentation inst)
This method is called when the agent is installed.void
run()
Profiler
startCollecting()
Start collecting profiling data.Profiler
stopCollecting()
Stop collecting.
-
-
-
Method Detail
-
premain
public static void premain(java.lang.String agentArgs, java.lang.instrument.Instrumentation inst)
This method is called when the agent is installed.- Parameters:
agentArgs
- the agent argumentsinst
- the instrumentation object
-
getInstrumentation
public static java.lang.instrument.Instrumentation getInstrumentation()
Get the instrumentation object if started as an agent.- Returns:
- the instrumentation, or null
-
main
public static void main(java.lang.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 interfacejava.lang.Runnable
-
getTop
public java.lang.String getTop(int count)
Get the top stack traces.- Parameters:
count
- the maximum number of stack traces- Returns:
- the stack traces.
-
-