diff --git a/src/test/java/com/iota/iri/benchmarks/BenchmarkRunner.java b/src/test/java/com/iota/iri/benchmarks/BenchmarkRunner.java index ef4a22af9c..119db7de39 100644 --- a/src/test/java/com/iota/iri/benchmarks/BenchmarkRunner.java +++ b/src/test/java/com/iota/iri/benchmarks/BenchmarkRunner.java @@ -8,19 +8,22 @@ import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; +import java.util.Optional; import java.util.concurrent.TimeUnit; public class BenchmarkRunner { @Test public void launchDbBenchmarks() throws RunnerException { + Options opts = new OptionsBuilder() .include(RocksDbBenchmark.class.getName() + ".*") .mode(Mode.AverageTime) .timeUnit(TimeUnit.MILLISECONDS) - .warmupIterations(5) - .forks(1) - .measurementIterations(10) + .warmupIterations(getWarmUpIterations(5)) + .forks(getForks(1)) + .threads(getThreads()) + .measurementIterations(getMeasurementIterations(10)) .shouldFailOnError(true) .shouldDoGC(false) .build(); @@ -32,15 +35,36 @@ public void launchDbBenchmarks() throws RunnerException { @Test public void launchCryptoBenchmark() throws RunnerException { Options opts = new OptionsBuilder() - .include(this.getClass().getPackage().getName() + ".crypto") - .mode(Mode.Throughput) - .timeUnit(TimeUnit.SECONDS) - .warmupIterations(5) - .forks(1) - .measurementIterations(10) - .shouldFailOnError(true) - .shouldDoGC(false) - .build(); + .include(this.getClass().getPackage().getName() + ".crypto") + .mode(Mode.Throughput) + .timeUnit(TimeUnit.SECONDS) + .warmupIterations(getWarmUpIterations(5)) + .forks(getForks(1)) + .threads(getThreads()) + .measurementIterations(getMeasurementIterations(10)) + .shouldFailOnError(true) + .shouldDoGC(false) + .build(); new Runner(opts).run(); } -} + + private int getThreads() { + return getProperty("threads", Integer.toString(Runtime.getRuntime().availableProcessors())); + } + + private int getForks(int defValue) { + return getProperty("forks", Integer.toString(defValue)); + } + + private int getWarmUpIterations(int defValue) { + return getProperty("warmUpIterations", Integer.toString(defValue)); + } + + private int getMeasurementIterations(int defValue) { + return getProperty("measurementIterations", Integer.toString(defValue)); + } + + private int getProperty(String property, String defValue){ + return Integer.valueOf(Optional.ofNullable(System.getProperty(property)).orElse(defValue)); + } +} \ No newline at end of file