Class AsyncProfiler

java.lang.Object
org.openjdk.jmh.profile.AsyncProfiler
All Implemented Interfaces:
ExternalProfiler, InternalProfiler, Profiler

public final class AsyncProfiler extends Object implements ExternalProfiler, InternalProfiler
A profiler based on async-profiler.
  • Field Details

    • instance

      private final AsyncProfiler.JavaApi instance
    • verbose

      private final boolean verbose
    • direction

      private final AsyncProfiler.Direction direction
    • profilerConfig

      private final String profilerConfig
    • output

      private final List<AsyncProfiler.OutputType> output
    • outputFilePrefix

      private final String outputFilePrefix
    • outDir

      private final File outDir
    • trialOutDir

      private 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 LinkedHashSet<File> generated
  • Constructor Details

  • Method Details

    • 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 interface InternalProfiler
      Parameters:
      benchmarkParams - benchmark parameters used for current launch
      iterationParams - iteration parameters used for current launch
    • start

      private void start()
    • afterIteration

      public 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 interface InternalProfiler
      Parameters:
      benchmarkParams - benchmark parameters used for current launch
      iterationParams - iteration parameters used for current launch
      iterationResult - iteration result
      Returns:
      profiler results
    • createTrialOutDir

      private void createTrialOutDir(BenchmarkParams benchmarkParams)
    • stopAndDump

      private TextResult stopAndDump()
    • dump

      private void dump(File target, String command)
    • outputFile

      private File outputFile(String fileNameFormat)
    • execute

      private String execute(String command)
    • addJVMInvokeOptions

      public Collection<String> addJVMInvokeOptions(BenchmarkParams params)
      Description copied from interface: ExternalProfiler
      Prepend JVM invocation with these commands.
      Specified by:
      addJVMInvokeOptions in interface ExternalProfiler
      Parameters:
      params - benchmark parameters used for current launch
      Returns:
      commands to prepend for JVM launch
    • addJVMOptions

      public Collection<String> addJVMOptions(BenchmarkParams params)
      Description copied from interface: ExternalProfiler
      Add JVM these options to the run.
      Specified by:
      addJVMOptions in interface ExternalProfiler
      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 interface ExternalProfiler
      Parameters:
      benchmarkParams - benchmark parameters used for current launch
    • afterTrial

      public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, 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 interface ExternalProfiler
      Parameters:
      br - benchmark result that was the result of the trial
      pid - pid that the forked JVM had
      stdOut - file containing the standard output from the benchmark JVM
      stdErr - 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 interface ExternalProfiler
      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 interface ExternalProfiler
      Returns:
      returns true, if profiler allows harness to print out the standard errpr
    • getDescription

      public String getDescription()
      Description copied from interface: Profiler
      Human-readable one-line description of the profiler.
      Specified by:
      getDescription in interface Profiler
      Returns:
      description