public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + TDigestBench.class.getSimpleName() + ".*") .resultFormat(ResultFormatType.CSV) .result("overall-results.csv") .addProfiler(GCProfiler.class) .build(); new Runner(opt).run(); } }
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + FloatHistogramBench.class.getSimpleName() + ".*") .resultFormat(ResultFormatType.CSV) .result("overall-results.csv") .addProfiler(StackProfiler.class) .addProfiler(GCProfiler.class) .build(); new Runner(opt).run(); }
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(MergeBench.class.getSimpleName()) .warmupIterations(5) .measurementIterations(5) .forks(1) .resultFormat(ResultFormatType.CSV) .build(); new Runner(opt).run(); }
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(".*" + Benchmark.class.getSimpleName() + ".*") .resultFormat(ResultFormatType.CSV) .result("results.csv") .addProfiler(GCProfiler.class) .addProfiler(StackProfiler.class) .build(); new Runner(opt).run(); }
runnerOptions.resultFormat(ResultFormatType.JSON); runnerOptions.result(filePath);
@Test public void run() throws Exception { final String className = getClass().getSimpleName(); final ChainedOptionsBuilder runnerOptions = new OptionsBuilder() .include(".*" + className + ".*") .jvmArgs(getJvmArgs()); if (getWarmupIterations() > 0) { runnerOptions.warmupIterations(getWarmupIterations()); } if (getMeasureIterations() > 0) { runnerOptions.measurementIterations(getMeasureIterations()); } if (getForks() > 0) { runnerOptions.forks(getForks()); } if (getReportDir() != null) { final String dtmStr = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); final String filePath = getReportDir() + className + "-" + dtmStr + ".json"; final File file = new File(filePath); if (file.exists()) { file.delete(); } else { file.getParentFile().mkdirs(); file.createNewFile(); } runnerOptions.resultFormat(ResultFormatType.JSON); runnerOptions.result(filePath); } new Runner(runnerOptions.build()).run(); }
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(); }
/** * Apply report option to {@link ChainedOptionsBuilder}. * * @param optionsBuilder must not be {@literal null}. * @return {@link ChainedOptionsBuilder} with options applied. * @throws IOException if report file cannot be created. * @see #getReportDirectory() */ private ChainedOptionsBuilder report(ChainedOptionsBuilder optionsBuilder, Class<?> jmhTestClass) throws IOException { String reportDir = getReportDirectory(); if (!StringUtils.hasText(reportDir)) { return optionsBuilder; } String reportFilePath = reportDir + (reportDir.endsWith(File.separator) ? "" : File.separator) + reportFilename(jmhTestClass); File file = new File(reportFilePath); if (file.exists()) { file.delete(); } else { file.getParentFile().mkdirs(); file.createNewFile(); } optionsBuilder.resultFormat(ResultFormatType.JSON); optionsBuilder.result(reportFilePath); return optionsBuilder; }
public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(FineGrainedLockBenchmark.class.getSimpleName()) .resultFormat(ResultFormatType.CSV) .build(); new Runner(opt).run(); } }
protected ChainedOptionsBuilder newOptionsBuilder() throws Exception { String className = getClass().getSimpleName(); ChainedOptionsBuilder runnerOptions = new OptionsBuilder() .include(".*" + className + ".*") .jvmArgs(jvmArgs()); if (getWarmupIterations() > 0) { runnerOptions.warmupIterations(getWarmupIterations()); } if (getMeasureIterations() > 0) { runnerOptions.measurementIterations(getMeasureIterations()); } if (getReportDir() != null) { String filePath = getReportDir() + className + ".json"; File file = new File(filePath); if (file.exists()) { file.delete(); } else { file.getParentFile().mkdirs(); file.createNewFile(); } runnerOptions.resultFormat(ResultFormatType.JSON); runnerOptions.result(filePath); } return runnerOptions; }
protected ChainedOptionsBuilder newOptionsBuilder() throws Exception { String className = getClass().getSimpleName(); ChainedOptionsBuilder runnerOptions = new OptionsBuilder() .include(".*" + className + ".*") .jvmArgs(jvmArgs()); if (getWarmupIterations() > 0) { runnerOptions.warmupIterations(getWarmupIterations()); } if (getMeasureIterations() > 0) { runnerOptions.measurementIterations(getMeasureIterations()); } if (getForks() > 0) { runnerOptions.forks(getForks()); } if (getReportDir() != null) { String filePath = getReportDir() + className + ".json"; File file = new File(filePath); if (file.exists()) { file.delete(); } else { file.getParentFile().mkdirs(); file.createNewFile(); } runnerOptions.resultFormat(ResultFormatType.JSON); runnerOptions.result(filePath); } return runnerOptions; }
public static void main(String... args) throws Exception { Options opts = new OptionsBuilder() .include(MapperBenchmark.class.getSimpleName()) .warmupIterations(5) .measurementIterations(5) .jvmArgs("-server") .forks(1) .resultFormat(ResultFormatType.TEXT) .build(); Collection<RunResult> results = new Runner(opts).run(); for (RunResult result : results) { Result<?> r = result.getPrimaryResult(); System.out.println("API replied benchmark score: " + r.getScore() + " " + r.getScoreUnit() + " over " + r.getStatistics().getN() + " iterations"); } }