Package org.openjdk.jmh.profile
Class AsyncProfiler
- java.lang.Object
-
- org.openjdk.jmh.profile.AsyncProfiler
-
- All Implemented Interfaces:
ExternalProfiler
,InternalProfiler
,Profiler
public final class AsyncProfiler extends java.lang.Object implements ExternalProfiler, InternalProfiler
A profiler based on async-profiler.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AsyncProfiler.CStackMode
static class
AsyncProfiler.Direction
static class
AsyncProfiler.JavaApi
static class
AsyncProfiler.OutputType
private static class
AsyncProfiler.ProfilerOptionsBuilder
-
Field Summary
Fields Modifier and Type Field Description private AsyncProfiler.Direction
direction
private int
flat
private java.util.LinkedHashSet<java.io.File>
generated
private AsyncProfiler.JavaApi
instance
private boolean
isVersion1x
private int
measurementIterationCount
private boolean
measurementStarted
private java.io.File
outDir
private java.util.List<AsyncProfiler.OutputType>
output
private java.lang.String
outputFilePrefix
private java.lang.String
profilerConfig
private int
traces
private java.io.File
trialOutDir
private boolean
verbose
private boolean
warmupStarted
-
Constructor Summary
Constructors Constructor Description AsyncProfiler(java.lang.String initLine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<java.lang.String>
addJVMInvokeOptions(BenchmarkParams params)
Prepend JVM invocation with these commands.java.util.Collection<java.lang.String>
addJVMOptions(BenchmarkParams params)
Add JVM these options to the run.java.util.Collection<? extends Result>
afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult)
Run this code after a benchmark iteration finishedjava.util.Collection<? extends Result>
afterTrial(BenchmarkResult br, long pid, java.io.File stdOut, java.io.File stdErr)
Run this code after the trial is done.boolean
allowPrintErr()
If target VM communicates with profiler with standard error, this method can be used to shun the output to console.boolean
allowPrintOut()
If target VM communicates with profiler with standard output, this method can be used to shun the output to console.void
beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams)
Run this code before starting the next benchmark iteration.void
beforeTrial(BenchmarkParams benchmarkParams)
Run this code before starting the trial.private void
createTrialOutDir(BenchmarkParams benchmarkParams)
private void
dump(java.io.File target, java.lang.String command)
private java.lang.String
execute(java.lang.String command)
java.lang.String
getDescription()
Human-readable one-line description of the profiler.private java.io.File
outputFile(java.lang.String fileNameFormat)
private void
start()
private TextResult
stopAndDump()
-
-
-
Field Detail
-
instance
private final AsyncProfiler.JavaApi instance
-
verbose
private final boolean verbose
-
direction
private final AsyncProfiler.Direction direction
-
profilerConfig
private final java.lang.String profilerConfig
-
output
private final java.util.List<AsyncProfiler.OutputType> output
-
outputFilePrefix
private final java.lang.String outputFilePrefix
-
outDir
private final java.io.File outDir
-
trialOutDir
private java.io.File trialOutDir
-
traces
private final int traces
-
flat
private final int flat
-
isVersion1x
private boolean isVersion1x
-
warmupStarted
private boolean warmupStarted
-
measurementStarted
private boolean measurementStarted
-
measurementIterationCount
private int measurementIterationCount
-
generated
private final java.util.LinkedHashSet<java.io.File> generated
-
-
Constructor Detail
-
AsyncProfiler
public AsyncProfiler(java.lang.String initLine) throws ProfilerException
- Throws:
ProfilerException
-
-
Method Detail
-
beforeIteration
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams)
Description copied from interface:InternalProfiler
Run this code before starting the next benchmark iteration.- Specified by:
beforeIteration
in interfaceInternalProfiler
- Parameters:
benchmarkParams
- benchmark parameters used for current launchiterationParams
- iteration parameters used for current launch
-
start
private void start()
-
afterIteration
public java.util.Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult)
Description copied from interface:InternalProfiler
Run this code after a benchmark iteration finished- Specified by:
afterIteration
in interfaceInternalProfiler
- Parameters:
benchmarkParams
- benchmark parameters used for current launchiterationParams
- iteration parameters used for current launchiterationResult
- iteration result- Returns:
- profiler results
-
createTrialOutDir
private void createTrialOutDir(BenchmarkParams benchmarkParams)
-
stopAndDump
private TextResult stopAndDump()
-
dump
private void dump(java.io.File target, java.lang.String command)
-
outputFile
private java.io.File outputFile(java.lang.String fileNameFormat)
-
execute
private java.lang.String execute(java.lang.String command)
-
addJVMInvokeOptions
public java.util.Collection<java.lang.String> addJVMInvokeOptions(BenchmarkParams params)
Description copied from interface:ExternalProfiler
Prepend JVM invocation with these commands.- Specified by:
addJVMInvokeOptions
in interfaceExternalProfiler
- Parameters:
params
- benchmark parameters used for current launch- Returns:
- commands to prepend for JVM launch
-
addJVMOptions
public java.util.Collection<java.lang.String> addJVMOptions(BenchmarkParams params)
Description copied from interface:ExternalProfiler
Add JVM these options to the run.- Specified by:
addJVMOptions
in interfaceExternalProfiler
- Parameters:
params
- benchmark parameters used for current launch- Returns:
- options to add to JVM launch
-
beforeTrial
public void beforeTrial(BenchmarkParams benchmarkParams)
Description copied from interface:ExternalProfiler
Run this code before starting the trial. This method will execute before starting the benchmark JVM.- Specified by:
beforeTrial
in interfaceExternalProfiler
- Parameters:
benchmarkParams
- benchmark parameters used for current launch
-
afterTrial
public java.util.Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, java.io.File stdOut, java.io.File stdErr)
Description copied from interface:ExternalProfiler
Run this code after the trial is done. This method will execute after benchmark JVM had stopped.- Specified by:
afterTrial
in interfaceExternalProfiler
- Parameters:
br
- benchmark result that was the result of the trialpid
- pid that the forked JVM hadstdOut
- file containing the standard output from the benchmark JVMstdErr
- file containing the standard error from the benchmark JVM- Returns:
- profiler results
-
allowPrintOut
public boolean allowPrintOut()
Description copied from interface:ExternalProfiler
If target VM communicates with profiler with standard output, this method can be used to shun the output to console. Profiler is responsible for consuming the standard output and printing the relevant data from there.- Specified by:
allowPrintOut
in interfaceExternalProfiler
- Returns:
- returns true, if profiler allows harness to print out the standard output
-
allowPrintErr
public boolean allowPrintErr()
Description copied from interface:ExternalProfiler
If target VM communicates with profiler with standard error, this method can be used to shun the output to console. Profiler is responsible for consuming the standard error and printing the relevant data from there.- Specified by:
allowPrintErr
in interfaceExternalProfiler
- Returns:
- returns true, if profiler allows harness to print out the standard errpr
-
getDescription
public java.lang.String getDescription()
Description copied from interface:Profiler
Human-readable one-line description of the profiler.- Specified by:
getDescription
in interfaceProfiler
- Returns:
- description
-
-