Package org.openjdk.jmh.profile
Class JavaFlightRecorderProfiler
- java.lang.Object
-
- org.openjdk.jmh.profile.JavaFlightRecorderProfiler
-
- All Implemented Interfaces:
ExternalProfiler,InternalProfiler,Profiler
public final class JavaFlightRecorderProfiler extends java.lang.Object implements ExternalProfiler, InternalProfiler
A profiler based on Java Flight Recorder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJavaFlightRecorderProfiler.PostProcessor
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringconfigNameprivate booleandebugNonSafePointsprivate java.util.Collection<java.lang.String>flightRecorderOptionsprivate java.util.List<java.io.File>generatedprivate intmeasurementIterationCountprivate booleanmeasurementStartedprivate java.io.FileoutDirprivate JavaFlightRecorderProfiler.PostProcessorpostProcessorprivate java.lang.StringprofileNameprivate booleanverbose
-
Constructor Summary
Constructors Constructor Description JavaFlightRecorderProfiler(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.booleanallowPrintErr()If target VM communicates with profiler with standard error, this method can be used to shun the output to console.booleanallowPrintOut()If target VM communicates with profiler with standard output, this method can be used to shun the output to console.voidbeforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams)Run this code before starting the next benchmark iteration.voidbeforeTrial(BenchmarkParams benchmarkParams)Run this code before starting the trial.private java.io.FilecreateTrialOutDir(BenchmarkParams benchmarkParams)private voidexecute(java.lang.String jvm, java.lang.String cmd, java.util.Collection<java.lang.String> options)private java.io.FilefindJcmd(java.lang.String jvm)java.lang.StringgetDescription()Human-readable one-line description of the profiler.private TextResultresult()
-
-
-
Field Detail
-
verbose
private final boolean verbose
-
outDir
private final java.io.File outDir
-
debugNonSafePoints
private final boolean debugNonSafePoints
-
configName
private final java.lang.String configName
-
flightRecorderOptions
private final java.util.Collection<java.lang.String> flightRecorderOptions
-
postProcessor
private JavaFlightRecorderProfiler.PostProcessor postProcessor
-
measurementStarted
private boolean measurementStarted
-
measurementIterationCount
private int measurementIterationCount
-
profileName
private java.lang.String profileName
-
generated
private final java.util.List<java.io.File> generated
-
-
Constructor Detail
-
JavaFlightRecorderProfiler
public JavaFlightRecorderProfiler(java.lang.String initLine) throws ProfilerException- Throws:
ProfilerException
-
-
Method Detail
-
beforeIteration
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams)
Description copied from interface:InternalProfilerRun this code before starting the next benchmark iteration.- Specified by:
beforeIterationin interfaceInternalProfiler- Parameters:
benchmarkParams- benchmark parameters used for current launchiterationParams- iteration parameters used for current launch
-
afterIteration
public java.util.Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult iterationResult)
Description copied from interface:InternalProfilerRun this code after a benchmark iteration finished- Specified by:
afterIterationin interfaceInternalProfiler- Parameters:
benchmarkParams- benchmark parameters used for current launchiterationParams- iteration parameters used for current launchiterationResult- iteration result- Returns:
- profiler results
-
result
private TextResult result()
-
createTrialOutDir
private java.io.File createTrialOutDir(BenchmarkParams benchmarkParams)
-
execute
private void execute(java.lang.String jvm, java.lang.String cmd, java.util.Collection<java.lang.String> options)
-
findJcmd
private java.io.File findJcmd(java.lang.String jvm)
-
addJVMInvokeOptions
public java.util.Collection<java.lang.String> addJVMInvokeOptions(BenchmarkParams params)
Description copied from interface:ExternalProfilerPrepend JVM invocation with these commands.- Specified by:
addJVMInvokeOptionsin 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:ExternalProfilerAdd JVM these options to the run.- Specified by:
addJVMOptionsin 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:ExternalProfilerRun this code before starting the trial. This method will execute before starting the benchmark JVM.- Specified by:
beforeTrialin 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:ExternalProfilerRun this code after the trial is done. This method will execute after benchmark JVM had stopped.- Specified by:
afterTrialin 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:ExternalProfilerIf 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:
allowPrintOutin interfaceExternalProfiler- Returns:
- returns true, if profiler allows harness to print out the standard output
-
allowPrintErr
public boolean allowPrintErr()
Description copied from interface:ExternalProfilerIf 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:
allowPrintErrin interfaceExternalProfiler- Returns:
- returns true, if profiler allows harness to print out the standard errpr
-
getDescription
public java.lang.String getDescription()
Description copied from interface:ProfilerHuman-readable one-line description of the profiler.- Specified by:
getDescriptionin interfaceProfiler- Returns:
- description
-
-