public static void main(String[] args) throws RunnerException, CommandLineOptionException { Options commandLineOptions = new CommandLineOptions( args ); ChainedOptionsBuilder builder = new OptionsBuilder().parent( commandLineOptions ); if ( !commandLineOptions.getResult().hasValue() ) { builder.result( "target/jmh-results.json" ); } if ( !commandLineOptions.getResultFormat().hasValue() ) { builder.resultFormat( ResultFormatType.JSON ); } if ( commandLineOptions.getIncludes().isEmpty() ) { DEFAULT_TEST_CLASSES.forEach( testClass -> builder.include( testClass.getName() ) ); } Options opt = builder.build(); new Runner( opt ).run(); }
@Override public Optional<Integer> getMeasurementIterations() { return Optional.eitherOf(iterations); }
public OutputFormat createOutputFormat(Options options) { // sadly required here as the check cannot be made before calling this method in // constructor if (options == null) { throw new IllegalArgumentException("Options not allowed to be null."); } PrintStream out; if (options.getOutput().hasValue()) { try { out = new PrintStream(options.getOutput().get()); } catch (FileNotFoundException ex) { throw new IllegalStateException(ex); } } else { // Protect the System.out from accidental closing try { out = new UnCloseablePrintStream(System.out, Utils.guessConsoleEncoding()); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } } return OutputFormatFactory.createFormatInstance(out, options.verbosity().orElse(Defaults.VERBOSITY)); } }
System.err.println("No matching benchmarks. Miss-spelled regexp?"); if (opts.verbosity().orElse(Defaults.VERBOSITY) != VerboseMode.EXTRA) { System.err.println("Use " + VerboseMode.EXTRA + " verbose mode to debug the pattern matching."); } else {
private static OutputFormat createOutputFormat(Options options) { // sadly required here as the check cannot be made before calling this method in // constructor if (options == null) { throw new IllegalArgumentException("Options not allowed to be null."); } PrintStream out; if (options.getOutput().hasValue()) { try { out = new PrintStream(options.getOutput().get()); } catch (FileNotFoundException ex) { throw new IllegalStateException(ex); } } else { // Protect the System.out from accidental closing try { out = new UnCloseablePrintStream(System.out, Utils.guessConsoleEncoding()); } catch (UnsupportedEncodingException ex) { throw new IllegalStateException(ex); } } return OutputFormatFactory.createFormatInstance(out, options.verbosity().orElse(Defaults.VERBOSITY)); }
@Override public Optional<Integer> getWarmupForkCount() { return Optional.eitherOf(warmupFork); }
@Override public Optional<Collection<String>> getJvmArgsAppend() { return Optional.eitherOf(jvmArgsAppend); }
@Override public Optional<String> getOutput() { return Optional.eitherOf(output); }
@Override public Optional<Boolean> shouldFailOnError() { return Optional.eitherOf(failOnError); }
@Override public Optional<Boolean> shouldDoGC() { return Optional.eitherOf(gcEachIteration); }
@Override public Optional<VerboseMode> verbosity() { return Optional.eitherOf(verbose); }
@Override public Optional<Integer> getThreads() { return Optional.eitherOf(threads); }
@Override public Optional<Integer> getForkCount() { return Optional.eitherOf(fork); }
@Override public Optional<Collection<String>> getJvmArgsPrepend() { return Optional.eitherOf(jvmArgsPrepend); }
@Override public Optional<ResultFormatType> getResultFormat() { return Optional.eitherOf(resultFormat); }
@Override public Optional<String> getResult() { return Optional.eitherOf(result); }
@Override public Optional<Boolean> shouldSyncIterations() { return Optional.eitherOf(synchIterations); }
@Override public Optional<Integer> getWarmupIterations() { return Optional.eitherOf(warmupIterations); }