@ThreadSafe
public final class Profiler
extends Object
implements Runnable
When configured to do so, will take periodic samples of all or some thread execution point, and / or take periodic snapshots of these threads. Sampling will conclude by a tally of the execution points; snapshots will provide tracebacks in the log.
All the configuration is done with System properties.
stop()
method will be ignored. This is
useful when looking for activities occuring after application stop
actions, like stuck threads. Defaults to false.Profiler.start(); try { // Section of code to be profiled . . . } finally { Profiler.stop(); }
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MARGIN
Default margin.
|
static String |
MARGIN_PROPERTY
Margin property.
|
static String |
SAMPLE_COUNT_PROPERTY
Sample count property.
|
static String |
SAMPLE_MILLIS_PROPERTY
Sample millis property.
|
static String |
SAMPLE_PRIORITY_PROPERTY
Sample priority property.
|
static String |
SNAPSHOT_COUNT_PROPERTY
Snapshot count property.
|
static String |
SNAPSHOT_DEPTH_PROPERTY
Snapshot depth property.
|
static String |
SNAPSHOT_MILLIS_PROPERTY
Snapshot millis property.
|
static String |
SNAPSHOT_PRIORITY_PROPERTY
Snapshot priority property.
|
static String |
START_MILLIS_PROPERTY
Start millis property.
|
static String |
STOP_IGNORED_PROPERTY
Stop ignored property.
|
static String |
THREAD_GROUP_PROPERTY
Thread group property.
|
static String |
THREAD_STATE_PROPERTY
Thread state property.
|
Modifier and Type | Method and Description |
---|---|
static String |
margin()
Returns the profile margin.
|
static void |
printStackTrace(Thread thread,
StackTraceElement[] stackTrace,
Optional<String> skippedName,
int stackDepth,
PrintWriter printWriter)
Prints a stack trace.
|
void |
run() |
static void |
start()
Starts the profiler
|
static void |
stop()
Stops the profiler.
|
public static final int DEFAULT_MARGIN
public static final String MARGIN_PROPERTY
public static final String SAMPLE_COUNT_PROPERTY
public static final String SAMPLE_MILLIS_PROPERTY
public static final String SAMPLE_PRIORITY_PROPERTY
public static final String SNAPSHOT_COUNT_PROPERTY
public static final String SNAPSHOT_DEPTH_PROPERTY
public static final String SNAPSHOT_MILLIS_PROPERTY
public static final String SNAPSHOT_PRIORITY_PROPERTY
public static final String START_MILLIS_PROPERTY
public static final String STOP_IGNORED_PROPERTY
public static final String THREAD_GROUP_PROPERTY
public static final String THREAD_STATE_PROPERTY
@Nonnull @CheckReturnValue public static String margin()
public static void printStackTrace(@Nonnull Thread thread, @Nonnull StackTraceElement[] stackTrace, @Nonnull Optional<String> skippedName, int stackDepth, @Nonnull PrintWriter printWriter)
thread
- The traced thread.stackTrace
- The stack trace.skippedName
- The optional skipped name for the current thread.stackDepth
- The stack depth.printWriter
- The print writer.public static void start()
public static void stop()
public void run()
run
in interface Runnable
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.