Command Line Runner accepts negative int arguments
Daniel Mitterdorfer
daniel.mitterdorfer at gmail.com
Tue May 19 18:43:51 UTC 2015
Hi,
the other day I've run a benchmark where I've defined the number of
iterations by a command line parameter. Instead of e.g. "-i 5" I've
mistyped it as "-i -5" (which is obviously not a good idea ;)).
However, JMH happily accepted the negative iteration count but did not run
any benchmark iterations and printed funny ETAs like "Run progress: -0,00%
complete, ETA 00:-1:-15".
I've looked at org.openjdk.jmh.runner.options.CommandLineOptions and indeed
there is no check on any of the int arguments for negative values.
To stick with my iteration example, instead of:
iterations = Optional.eitherOf(optMeasureCount.value(set));
I'd expect something along the lines of:
if (set.has(optMeasureCount)) {
Integer value = optMeasureCount.value(set);
if (value <= 0) {
throw new CommandLineOptionException("Encountered " + value + " but
expected a positive value");
}
iterations = Optional.of(value);
}
To be honest, I don't think that it is such a big problem but fixing it
would make for a more robust user experience.
Bye,
Daniel
More information about the jmh-dev
mailing list