Package org.h2.util
Class Profiler
java.lang.Object
org.h2.util.Profiler
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionint
private final String[]
private final String[]
private final String[]
private static Instrumentation
int
private static final String
private static final int
private int
boolean
private int
private long
private boolean
boolean
The summary (usually one entry per package, unless sumClasses is enabled, in which case it's one entry per class).boolean
private Thread
private int
private long
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
appendTop
(StringBuilder buff, HashMap<String, Integer> map, int count, int total, boolean table) private static void
copyInThread
(InputStream in, OutputStream out) private static String
static Instrumentation
Get the instrumentation object if started as an agent.getTop
(int count) Get the top stack traces.private String
getTopTraces
(int count) private static int
static void
Run the command line version of the profiler.static void
premain
(String agentArgs, Instrumentation inst) This method is called when the agent is installed.private void
processList
(List<Object[]> list) readRunnableStackTraces
(int pid) void
run()
private void
Start collecting profiling data.private static boolean
startsWithAny
(String s, String[] prefixes) Stop collecting.private void
tick()
-
Field Details
-
instrumentation
-
LINE_SEPARATOR
-
MAX_ELEMENTS
private static final int MAX_ELEMENTS- See Also:
-
interval
public int interval -
depth
public int depth -
paused
public boolean paused -
sumClasses
public boolean sumClasses -
sumMethods
public boolean sumMethods -
pid
private int pid -
ignoreLines
-
ignorePackages
-
ignoreThreads
-
stop
private volatile boolean stop -
counts
-
summary
The summary (usually one entry per package, unless sumClasses is enabled, in which case it's one entry per class). -
minCount
private int minCount -
total
private int total -
thread
-
start
private long start -
time
private long time -
threadDumps
private int threadDumps
-
-
Constructor Details
-
Profiler
public Profiler()
-
-
Method Details
-
premain
This method is called when the agent is installed.- Parameters:
agentArgs
- the agent argumentsinst
- the instrumentation object
-
getInstrumentation
Get the instrumentation object if started as an agent.- Returns:
- the instrumentation, or null
-
main
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
-
run
-
getRunnableStackTraces
-
readRunnableStackTraces
-
readStackTrace
- Throws:
IOException
-
exec
-
copyInThread
-
startCollecting
Start collecting profiling data.- Returns:
- this
-
stopCollecting
Stop collecting.- Returns:
- this
-
run
public void run() -
tick
private void tick() -
processList
-
startsWithAny
-
increment
-
getTop
Get the top stack traces.- Parameters:
count
- the maximum number of stack traces- Returns:
- the stack traces.
-
getTopTraces
-
appendTop
private static void appendTop(StringBuilder buff, HashMap<String, Integer> map, int count, int total, boolean table)
-