Here are the examples of the java api class com.google.caliper.model.BenchmarkSpec taken from open source projects.
1. WorkerProcessTest#simpleArgsTest()
Project: caliper
File: WorkerProcessTest.java
File: WorkerProcessTest.java
@Test public void simpleArgsTest() throws Exception { Method method = TestBenchmark.class.getDeclaredMethods()[0]; AllocationInstrument allocationInstrument = new AllocationInstrument(); allocationInstrument.setOptions(ImmutableMap.of("trackAllocations", "true")); VmConfig vmConfig = new VmConfig(new File("foo"), Arrays.asList("--doTheHustle"), new File("java"), new JvmPlatform()); Experiment experiment = new Experiment(allocationInstrument.createInstrumentation(method), ImmutableMap.<String, String>of(), new VirtualMachine("foo-jvm", vmConfig)); BenchmarkSpec spec = new BenchmarkSpec.Builder().className(TestBenchmark.class.getName()).methodName(method.getName()).build(); ProcessBuilder builder = createProcess(experiment, spec); List<String> commandLine = builder.command(); assertEquals(new File("java").getAbsolutePath(), commandLine.get(0)); // vm specific flags come next assertEquals("--doTheHustle", commandLine.get(1)); // then the classpath assertEquals("-cp", commandLine.get(2)); // should we assert on classpath contents? ImmutableSet<String> extraCommandLineArgs = allocationInstrument.getExtraCommandLineArgs(vmConfig); assertEquals(extraCommandLineArgs.asList(), commandLine.subList(4, 4 + extraCommandLineArgs.size())); int index = 4 + extraCommandLineArgs.size(); assertEquals("-XX:+PrintFlagsFinal", commandLine.get(index)); assertEquals("-XX:+PrintCompilation", commandLine.get(++index)); assertEquals("-XX:+PrintGC", commandLine.get(++index)); assertEquals(WorkerMain.class.getName(), commandLine.get(++index)); // followed by worker args... }