Class 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.

    • Constructor Detail

      • 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 Detail

      • 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
      • runBenchmarksForked

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

        protected void etaAfterBenchmark​(BenchmarkParams params)
      • 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