public abstract class Sampler extends Object
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the self-sampling.
|
static Sampler |
createManualSampler(String name)
Factory method for creating Sampler suitable for manual or user invoked
scanning.
|
static Sampler |
createSampler(String name)
Factory method for creating Sampler suitable for automatic reporting
of the slow operation (i.e.
|
void |
start()
Start self-sampling.
|
void |
stop()
Stop the self-sampling, save and open gathered data.
|
void |
stopAndWriteTo(DataOutputStream dos)
Stop the self-sampling started by
Sampler.start() method and writes the data to
DataOutputStream . |
@CheckForNull public static Sampler createSampler(@NonNull String name)
null
if the sampled application is in nonstandard mode
which will produce unrealistic data - for example application is
running under debugger or profiler. It can return null
if it
is running on some exotic variant of JDK, where sampling is not supported.name
- which identifies the sampler threadSampler
or null
if application
is in nonstandard mode or sampling is not supported.@CheckForNull public static Sampler createManualSampler(@NonNull String name)
null
if it is running on
some exotic variant of JDK, where sampling is not supported.name
- which identifies the sampler threadSampler
or null
if sampling
is not supported.public final void start()
name
for actual sampling and returns immediately.public final void cancel()
public final void stopAndWriteTo(@NonNull DataOutputStream dos)
Sampler.start()
method and writes the data to
DataOutputStream
. If the internal sampling logic detects that
the data are distorted for example due to heavy system I/O, collected
samples are discarded and nothing is written to DataOutputStream
.
dos
- DataOutputStream
where sampled data is written to.public final void stop()