public class AsyncProfiler extends java.lang.Object implements AsyncProfilerMXBean
getInstance()
initiates loading of
libasyncProfiler.so.Modifier and Type | Method and Description |
---|---|
void |
addThread(java.lang.Thread thread)
Add the given thread to the set of profiled threads.
|
java.lang.String |
dumpCollapsed(Counter counter)
Dump profile in 'collapsed stacktraces' format
|
java.lang.String |
dumpFlat(int maxMethods)
Dump flat profile, i.e. the histogram of the hottest methods
|
java.lang.String |
dumpTraces(int maxTraces)
Dump collected stack traces
|
java.lang.String |
execute(java.lang.String command)
Execute an agent-compatible profiling command -
the comma-separated list of arguments described in arguments.cpp
|
static AsyncProfiler |
getInstance() |
static AsyncProfiler |
getInstance(java.lang.String libPath) |
long |
getSamples()
Get the number of samples collected during the profiling session
|
java.lang.String |
getVersion()
Get profiler agent version, e.g. "1.0"
|
void |
removeThread(java.lang.Thread thread)
Remove the given thread from the set of profiled threads.
|
void |
resume(java.lang.String event,
long interval)
Start or resume profiling without resetting collected data.
|
void |
start(java.lang.String event,
long interval)
Start profiling
|
void |
stop()
Stop profiling (without dumping results)
|
public static AsyncProfiler getInstance()
public static AsyncProfiler getInstance(java.lang.String libPath)
public void start(java.lang.String event, long interval) throws java.lang.IllegalStateException
start
in interface AsyncProfilerMXBean
event
- Profiling event, see Events
interval
- Sampling interval, e.g. nanoseconds for Events.CPUjava.lang.IllegalStateException
- If profiler is already runningpublic void resume(java.lang.String event, long interval) throws java.lang.IllegalStateException
resume
in interface AsyncProfilerMXBean
event
- Profiling event, see Events
interval
- Sampling interval, e.g. nanoseconds for Events.CPUjava.lang.IllegalStateException
- If profiler is already runningpublic void stop() throws java.lang.IllegalStateException
stop
in interface AsyncProfilerMXBean
java.lang.IllegalStateException
- If profiler is not runningpublic long getSamples()
getSamples
in interface AsyncProfilerMXBean
public java.lang.String getVersion()
getVersion
in interface AsyncProfilerMXBean
public java.lang.String execute(java.lang.String command) throws java.lang.IllegalArgumentException, java.io.IOException
execute
in interface AsyncProfilerMXBean
command
- Profiling commandjava.lang.IllegalArgumentException
- If failed to parse the commandjava.io.IOException
- If failed to create output filepublic java.lang.String dumpCollapsed(Counter counter)
dumpCollapsed
in interface AsyncProfilerMXBean
counter
- Which counter to display in the outputpublic java.lang.String dumpTraces(int maxTraces)
dumpTraces
in interface AsyncProfilerMXBean
maxTraces
- Maximum number of stack traces to dump. 0 means no limitpublic java.lang.String dumpFlat(int maxMethods)
dumpFlat
in interface AsyncProfilerMXBean
maxMethods
- Maximum number of methods to dump. 0 means no limitpublic void addThread(java.lang.Thread thread)
thread
- Thread to include in profilingpublic void removeThread(java.lang.Thread thread)
thread
- Thread to exclude from profiling