Runner API: jmh command line arguments propagation

Aleksey Shipilev aleksey.shipilev at oracle.com
Tue Nov 19 07:23:39 PST 2013


Hi,

On 11/19/2013 05:05 PM, Sergey Kuksenko wrote:
> There is a strong necessity to set execution options from command line.
> I have a full freedom to do it myself right now, because of I am writing
> the main. But I'd like not to invent a wheel and use some standard API.
> Mainly I need it to specify forked JVM parameters, and I wouldn't argue
> to get it also for jmh parameters.

So the use case is ramping up your own launcher which accepts the same
parameters like JMH launcher, and then feeds them mixed with some new
parameters to the JMH Runner?

The caveat here is, JMH API and JMH CLI launcher are separate, sharing
nothing in common except for the interface. You can not easily tell
API-ish OptionBuilder to filter out JMH CLI parameters, because it is
not aware even of the existence of CLI launcher.

Hence, I can only recommend two things:
 A) Give up JMH CLI compatibility and accept some custom options in your
custom main(), then feed them into JMH API;
 B) Reuse CommandLineOptions class to parse out the Options from
String[], manipulate (extend?) that class, and then use it as the Option
instance for the Runner. Just like the regular JMH launcher does.

Thanks,
-Aleksey.


More information about the jmh-dev mailing list