OpenJDK / code-tools / jmh
changeset 1448:56576f4dc727
7902165: Reconsider defaults for warmup and measurement iteration counts, durations
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Defaults.java Thu May 03 20:30:22 2018 +0200 @@ -40,7 +40,7 @@ /** * Number of warmup iterations. */ - public static final int WARMUP_ITERATIONS = 20; + public static final int WARMUP_ITERATIONS = 5; /** * Number of warmup iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. @@ -55,12 +55,12 @@ /** * The duration of warmup iterations. */ - public static final TimeValue WARMUP_TIME = TimeValue.seconds(1); + public static final TimeValue WARMUP_TIME = TimeValue.seconds(10); /** * Number of measurement iterations. */ - public static final int MEASUREMENT_ITERATIONS = 20; + public static final int MEASUREMENT_ITERATIONS = 5; /** * Number of measurement iterations in {@link org.openjdk.jmh.annotations.Mode#SingleShotTime} mode. @@ -75,7 +75,7 @@ /** * The duration of measurement iterations. */ - public static final TimeValue MEASUREMENT_TIME = TimeValue.seconds(1); + public static final TimeValue MEASUREMENT_TIME = TimeValue.seconds(10); /** * Number of measurement threads.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java Thu May 03 20:30:22 2018 +0200 @@ -161,8 +161,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_02 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_02 -f 1 + * (we requested a single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -172,8 +172,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_02_BenchmarkModes.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java Thu May 03 20:30:22 2018 +0200 @@ -105,8 +105,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_03 -wi 5 -i 5 -t 4 -f 1 - * (we requested 5 measurement/warmup iterations, with 4 threads, single fork) + * $ java -jar target/benchmarks.jar JMHSample_03 -t 4 -f 1 + * (we requested 4 threads, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -116,8 +116,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_03_States.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(4) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java Thu May 03 20:30:22 2018 +0200 @@ -64,8 +64,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_04 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_04 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -75,8 +75,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_04_DefaultState.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java Thu May 03 20:30:22 2018 +0200 @@ -111,8 +111,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -ea -jar target/benchmarks.jar JMHSample_05 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -ea -jar target/benchmarks.jar JMHSample_05 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -122,8 +122,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_05_StateFixtures.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .jvmArgs("-ea") .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java Thu May 03 20:30:22 2018 +0200 @@ -82,8 +82,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -ea -jar target/benchmarks.jar JMHSample_06 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -ea -jar target/benchmarks.jar JMHSample_06 -f 1 + * (we requested single fork; there are also other options, see -h) * * You can optionally supply -foe to fail the complete run. * @@ -95,8 +95,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_06_FixtureLevel.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .jvmArgs("-ea") .shouldFailOnError(false) // switch to "true" to fail the complete run
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java Thu May 03 20:30:22 2018 +0200 @@ -148,8 +148,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_07 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_07 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -159,8 +159,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_07_FixtureLevelInvocation.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java Thu May 03 20:30:22 2018 +0200 @@ -84,8 +84,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_08 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_08 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -95,8 +95,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_08_DeadCode.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java Thu May 03 20:30:22 2018 +0200 @@ -112,8 +112,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_09 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_09 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -123,8 +123,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_09_Blackholes.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java Thu May 03 20:30:22 2018 +0200 @@ -98,7 +98,7 @@ * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_10 -i 5 -f 1 - * (we requested 5 iterations, single fork) + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -108,8 +108,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_10_ConstantFold.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java Thu May 03 20:30:22 2018 +0200 @@ -138,8 +138,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_11 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_11 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -149,8 +149,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_11_Loops.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java Thu May 03 20:30:22 2018 +0200 @@ -167,8 +167,7 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_12 -wi 5 -i 5 - * (we requested 5 warmup/measurement iterations) + * $ java -jar target/benchmarks.jar JMHSample_12 * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -178,8 +177,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_12_Forking.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .build(); new Runner(opt).run();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java Thu May 03 20:30:22 2018 +0200 @@ -109,7 +109,7 @@ * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_13 -wi 0 -i 3 - * (we requested no warmup, 3 measurement iterations) + * (we requested no warmup, 3 measurement iterations; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -120,7 +120,7 @@ Options opt = new OptionsBuilder() .include(JMHSample_13_RunToRun.class.getSimpleName()) .warmupIterations(0) - .measurementIterations(5) + .measurementIterations(3) .build(); new Runner(opt).run();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java Thu May 03 20:30:22 2018 +0200 @@ -107,8 +107,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_15 -wi 5 -i 5 -f 1 - * (we requested 5 warmup/measurement iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_15 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -118,8 +118,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_15_Asymmetric.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java Thu May 03 20:30:22 2018 +0200 @@ -124,8 +124,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_16 -wi 1 -i 3 -f 1 - * (we requested 1 warmup iterations, 3 iterations, single fork) + * $ java -jar target/benchmarks.jar JMHSample_16 -wi 0 -i 3 -f 1 + * (we requested no warmup iterations, 3 iterations, single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -135,7 +135,7 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_16_CompilerControl.class.getSimpleName()) - .warmupIterations(1) + .warmupIterations(0) .measurementIterations(3) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java Thu May 03 20:30:22 2018 +0200 @@ -38,6 +38,7 @@ import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; +import org.openjdk.jmh.runner.options.TimeValue; import java.util.concurrent.TimeUnit; @@ -103,8 +104,8 @@ * a) Via the command line: * $ mvn clean install * $ java -jar target/benchmarks.jar JMHSample_17 \ - * -i 20 -wi 1 -f 1 -t ${CPU*16} -si {true|false} - * (we requested 1 warmup iterations, 20 iterations, single fork, + * -w 1s -r 1s -f 1 -t ${CPU*16} -si {true|false} + * (we requested shorter warmup/measurement iterations, single fork, * lots of threads, and changeable "synchronize iterations" option) * * b) Via the Java API: @@ -115,8 +116,8 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_17_SyncIterations.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(20) + .warmupTime(TimeValue.seconds(1)) + .measurementTime(TimeValue.seconds(1)) .threads(Runtime.getRuntime().availableProcessors()*16) .forks(1) .syncIterations(true) // try to switch to "false"
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java Thu May 03 20:30:22 2018 +0200 @@ -84,8 +84,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_18 -wi 1 -i 5 -t 2 -f 1 - * (we requested 1 warmup iterations, 5 iterations, 2 threads, and single fork) + * $ java -jar target/benchmarks.jar JMHSample_18 -t 2 -f 1 + * (we requested 2 threads and single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -95,8 +95,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_18_Control.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(5) .threads(2) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java Thu May 03 20:30:22 2018 +0200 @@ -128,7 +128,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_21 -w 1 -i 5 -f 1 + * $ java -jar target/benchmarks.jar JMHSample_21 -f 1 + * (we requested single fork; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -138,8 +139,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_21_ConsumeCPU.class.getSimpleName()) - .warmupIterations(1) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_30_Interrupts.java Thu May 03 20:30:22 2018 +0200 @@ -101,8 +101,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_30 -wi 5 -i 5 -t 2 -f 5 -to 5 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, 5 forks, and 5 sec timeout) + * $ java -jar target/benchmarks.jar JMHSample_30 -t 2 -f 5 -to 10 + * (we requested 2 threads, 5 forks, and 10 sec timeout) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -112,11 +112,9 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_30_Interrupts.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(2) .forks(5) - .timeout(TimeValue.seconds(5)) + .timeout(TimeValue.seconds(10)) .build(); new Runner(opt).run();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_31_InfraParams.java Thu May 03 20:30:22 2018 +0200 @@ -120,8 +120,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_31 -wi 5 -i 5 -t 4 -f 5 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, and 5 forks) + * $ java -jar target/benchmarks.jar JMHSample_31 -t 4 -f 5 + * (we requested 4 threads, and 5 forks; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -131,8 +131,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_31_InfraParams.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .threads(4) .forks(5) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_32_BulkWarmup.java Thu May 03 20:30:22 2018 +0200 @@ -129,8 +129,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wi 5 -i 5 -wm BULK - * (we requested a single fork, 5 warmup/measurement iterations, and bulk warmup mode) + * $ java -jar target/benchmarks.jar JMHSample_32 -f 1 -wm BULK + * (we requested a single fork, and bulk warmup mode; there are also other options, see -h) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE: @@ -142,8 +142,6 @@ .include(JMHSample_32_BulkWarmup.class.getSimpleName()) // .includeWarmup(...) <-- this may include other benchmarks into warmup .warmupMode(WarmupMode.BULK) // see other WarmupMode.* as well - .warmupIterations(5) - .measurementIterations(5) .forks(1) .build();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_33_SecurityManager.java Thu May 03 20:30:22 2018 +0200 @@ -117,8 +117,8 @@ * * a) Via the command line: * $ mvn clean install - * $ java -jar target/benchmarks.jar JMHSample_33 -wi 5 -i 5 -f 1 - * (we requested 5 warmup iterations, 5 iterations, 2 threads, 5 forks) + * $ java -jar target/benchmarks.jar JMHSample_33 -f 1 + * (we requested 5 warmup iterations, 5 forks; there are also other options, see -h)) * * b) Via the Java API: * (see the JMH homepage for possible caveats when running from IDE:
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java Thu May 03 15:11:12 2018 +0200 +++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_34_SafeLooping.java Thu May 03 20:30:22 2018 +0200 @@ -194,8 +194,6 @@ public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder() .include(JMHSample_34_SafeLooping.class.getSimpleName()) - .warmupIterations(5) - .measurementIterations(5) .forks(3) .build();