Class Runner

java.lang.Object
org.openjdk.jmh.runner.Runner

public class Runner extends Object
Runner executes JMH benchmarks.

This is the entry point for JMH Java API.

Runner is not usually reusable. After you execute any method on the Runner, you should digest the results, give up on current Runner, and instantiate another one. This class may be turned into static class in future releases.

  • Field Details

  • Constructor Details

    • Runner

      public Runner(Options options, OutputFormat format)
      Create runner with the custom OutputFormat.
      Parameters:
      options - options to use
      format - OutputFormat to use
    • Runner

      public Runner(Options options)
      Create Runner with the given options. This method sets up the OutputFormat as mandated by options.
      Parameters:
      options - options to use.
  • Method Details

    • list

      public void list()
      Print matching benchmarks into output.
    • listWithParams

      public void listWithParams(CommandLineOptions options)
      Print matching benchmarks with parameters into output.
      Parameters:
      options - options to use.
    • runSingle

      public RunResult runSingle() throws RunnerException
      Shortcut method for the single benchmark execution. This method is handy when Options describe only the single benchmark to run.
      Returns:
      benchmark result
      Throws:
      RunnerException - if more than one benchmark is found, or no results are returned
    • run

      public Collection<RunResult> run() throws RunnerException
      Run benchmarks.
      Returns:
      map of benchmark results
      Throws:
      RunnerException - if something goes wrong
    • runBenchmarksForked

      protected void runBenchmarksForked(ActionPlan actionPlan, org.openjdk.jmh.runner.IterationResultAcceptor acceptor)
    • runBenchmarksEmbedded

      protected Multimap<BenchmarkParams,BenchmarkResult> runBenchmarksEmbedded(ActionPlan actionPlan)
    • etaAfterBenchmark

      protected void etaAfterBenchmark(BenchmarkParams params)
    • etaBeforeBenchmarks

      protected void etaBeforeBenchmarks(Collection<ActionPlan> plans)
    • etaBeforeBenchmark

      protected void etaBeforeBenchmark()
    • etaAfterBenchmarks

      protected void etaAfterBenchmarks()
    • runBenchmark

      protected void runBenchmark(BenchmarkParams benchParams, org.openjdk.jmh.runner.BenchmarkHandler handler, org.openjdk.jmh.runner.IterationResultAcceptor acceptor)
    • runSystemGC

      public boolean runSystemGC()
      Execute System.gc() if we the System.gc option is set.
      Returns:
      true if we did