/* Copyright (c) 2008-2018, Nathan Sweet
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
 * conditions are met:
 * 
 * - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided with the distribution.
 * - Neither the name of Esoteric Software nor the names of its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
 * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.openjdk.jmh.Main;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

public class KryoBenchmarks {
	/** To run, in command-line: $ mvn clean install exec:java -Dexec.args="-wi 10 -i 10" */
	public static void main (String[] args) throws Exception {

		org.apache.commons.cli.Options cliOptions = new org.apache.commons.cli.Options();

		Option includeOption = Option.builder("incl").argName("include").hasArg().build();
		Option forksOption = Option.builder("f").argName("forks").hasArg().build();
		Option warmupIterationsOption = Option.builder("wi").argName("warmupIterations").hasArg().build();
		Option iterationsOption = Option.builder("i").argName("iterations").hasArg().build();
		Option threadsOption = Option.builder("t").argName("threads").hasArg().build();

		cliOptions.addOption(includeOption);
		cliOptions.addOption(forksOption);
		cliOptions.addOption(warmupIterationsOption);
		cliOptions.addOption(iterationsOption);
		cliOptions.addOption(threadsOption);

		CommandLineParser parser = new DefaultParser();
		CommandLine cl = parser.parse(cliOptions, args);

		String include = cl.getOptionValue(includeOption.getOpt(), "Benchmark");
		int forks = intValue(cl, forksOption, "1");
		int warmupIterations = intValue(cl, warmupIterationsOption, "10");
		int iterations = intValue(cl, iterationsOption, "5");
		int threads = intValue(cl, threadsOption, "1");

		Options options = new OptionsBuilder().include(include).forks(forks)
			// .mode(Mode.SampleTime)
			// .timeUnit(TimeUnit.NANOSECONDS)
			.warmupIterations(warmupIterations).measurementIterations(iterations).threads(threads).build();

		//new Runner(options).run();
		Main.main(args);
	}

	private static int intValue (CommandLine cl, Option o, String defaultValue) {
		return Integer.parseInt(cl.getOptionValue(o.getOpt(), defaultValue));
	}
}

@@ -1582,338 +1582,24 @@
 org.
-apache.commons.cli.CommandLine;%0Aimport org.apache.commons.cli.CommandLineParser;%0Aimport org.apache.commons.cli.DefaultParser;%0Aimport org.apache.commons.cli.Option;%0Aimport org.openjdk.jmh.Main;%0Aimport org.openjdk.jmh.runner.Runner;%0Aimport org.openjdk.jmh.runner.options.Options;%0Aimport org.openjdk.jmh.runner.options.OptionsBuilder
+openjdk.jmh.Main
 ;%0A%0Ap
@@ -1700,16 +1700,21 @@
 c.args=%22
+-f 1 
 -wi 10 -
@@ -1717,16 +1717,21 @@
 10 -i 10
+ -t 1
 %22 */%0A%09pu
@@ -1791,1574 +1791,24 @@
 n %7B%0A
-%0A%09%09org.apache.commons.cli.Options cliOptions = new org.apache.commons.cli.Options();%0A%0A%09%09Option includeOption = Option.builder(%22incl%22).argName(%22include%22).hasArg().build();%0A%09%09Option forksOption = Option.builder(%22f%22).argName(%22forks%22).hasArg().build();%0A%09%09Option warmupIterationsOption = Option.builder(%22wi%22).argName(%22warmupIterations%22).hasArg().build();%0A%09%09Option iterationsOption = Option.builder(%22i%22).argName(%22iterations%22).hasArg().build();%0A%09%09Option threadsOption = Option.builder(%22t%22).argName(%22threads%22).hasArg().build();%0A%0A%09%09cliOptions.addOption(includeOption);%0A%09%09cliOptions.addOption(forksOption);%0A%09%09cliOptions.addOption(warmupIterationsOption);%0A%09%09cliOptions.addOption(iterationsOption);%0A%09%09cliOptions.addOption(threadsOption);%0A%0A%09%09CommandLineParser parser = new DefaultParser();%0A%09%09CommandLine cl = parser.parse(cliOptions, args);%0A%0A%09%09String include = cl.getOptionValue(includeOption.getOpt(), %22Benchmark%22);%0A%09%09int forks = intValue(cl, forksOption, %221%22);%0A%09%09int warmupIterations = intValue(cl, warmupIterationsOption, %2210%22);%0A%09%09int iterations = intValue(cl, iterationsOption, %225%22);%0A%09%09int threads = intValue(cl, threadsOption, %221%22);%0A%0A%09%09Options options = new OptionsBuilder().include(include).forks(forks)%0A%09%09%09// .mode(Mode.SampleTime)%0A%09%09%09// .timeUnit(TimeUnit.NANOSECONDS)%0A%09%09%09.warmupIterations(warmupIterations).measurementIterations(iterations).threads(threads).build();%0A%0A%09%09//new Runner(options).run();%0A%09%09Main.main(args);%0A%09%7D%0A%0A%09private static int intValue (CommandLine cl, Option o, String defaultValue) %7B%0A%09%09return Integer.parseInt(cl.getOptionValue(o.getOpt(), defaultValue)
+%09%09Main.main(args
 );%0A%09

Use Main.main for JMH CLI.