changeset 195:7fcc14fb37a7

Adjust JMH samples for the new defaults.
author shade
date Mon, 07 Oct 2013 14:50:30 +0400
parents b7403ff13303
children 78886630f76c
files jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_22_FalseSharing.java
diffstat 19 files changed, 36 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java	Mon Oct 07 14:50:30 2013 +0400
@@ -123,8 +123,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_02.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_02.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You are expected to see the different run modes for the same benchmark.
      * Note the units are different, scores are consistent with each other.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_03_States.java	Mon Oct 07 14:50:30 2013 +0400
@@ -90,8 +90,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_03.*" -i 5 -r 1s -t 4
-     *    (we requested 5 iterations, 1 sec each, with 4 threads)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_03.*" -i 5 -t 4 -f 1
+     *    (we requested 5 iterations, with 4 threads, single fork)
      *
      * You are expected to see the drastic difference in shared and unshared cases,
      * because you either contend for single memory location, or not. This effect
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_04_DefaultState.java	Mon Oct 07 14:50:30 2013 +0400
@@ -50,8 +50,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_04.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_04.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see the benchmark runs as usual.
      */
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_05_StateFixtures.java	Mon Oct 07 14:50:30 2013 +0400
@@ -98,8 +98,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -ea -jar target/microbenchmarks.jar ".*JMHSample_05.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -ea -jar target/microbenchmarks.jar ".*JMHSample_05.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see measureRight() yields the result, and measureWrong() fires
      * the assert at the end of the run.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_06_FixtureLevel.java	Mon Oct 07 14:50:30 2013 +0400
@@ -68,8 +68,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -ea -jar target/microbenchmarks.jar ".*JMHSample_06.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -ea -jar target/microbenchmarks.jar ".*JMHSample_06.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see measureRight() yields the result, and measureWrong() fires
      * the assert at the end of first iteration!
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java	Mon Oct 07 14:50:30 2013 +0400
@@ -147,8 +147,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_07.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_07.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see the cold scenario is running longer, because we pay for
      * thread wakeups.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java	Mon Oct 07 14:50:30 2013 +0400
@@ -72,8 +72,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_08.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_08.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see the unrealistically fast calculation in with measureWrong(),
      * while realistic measurement with measureRight().
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java	Mon Oct 07 14:50:30 2013 +0400
@@ -99,8 +99,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_09.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_09.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You will see measureWrong() running on-par with baseline().
      * Both measureRight() are measuring twice the baseline, so the logs are intact.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java	Mon Oct 07 14:50:30 2013 +0400
@@ -74,8 +74,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_10.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_10.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You can see the unrealistically fast calculation in with measureWrong(),
      * while realistic measurement with measureRight().
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java	Mon Oct 07 14:50:30 2013 +0400
@@ -124,8 +124,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_11.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_11.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You might notice the larger the repetitions count, the lower the "perceived"
      * cost of the operation being measured. Up to the point we do each addition with 1/20 ns,
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java	Mon Oct 07 14:50:30 2013 +0400
@@ -156,8 +156,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_12.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_12.*" -i 5
+     *    (we requested 5 iterations)
      *
      * Note that C1 is faster, C2 is slower, but the C1 is slow again! This is because
      * the profiles for C1 and C2 had merged together. Notice how flawless the measurement
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java	Mon Oct 07 14:50:30 2013 +0400
@@ -93,8 +93,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_13.*" -wi 0 -i 3 -r 1s
-     *    (we requested no warmup, 3 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_13.*" -wi 0 -i 3
+     *    (we requested no warmup, 3 measurement iterations)
      *
      * Note the baseline is random within [0..1000] msec; and both forked runs
      * are estimating the average 500 msec with some confidence.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java	Mon Oct 07 14:50:30 2013 +0400
@@ -90,8 +90,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_15.*" -i 5 -r 1s
-     *    (we requested 5 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_15.*" -i 5 -f 1
+     *    (we requested 5 iterations, single fork)
      *
      * You will have the distinct metrics for inc() and get() from this run.
      */
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java	Mon Oct 07 14:50:30 2013 +0400
@@ -108,8 +108,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_16.*" -wi 1 -i 3 -r 1s
-     *    (we requested 1 warmup iterations, 3 iterations, 1 sec each)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_16.*" -wi 1 -i 3 -f 1
+     *    (we requested 1 warmup iterations, 3 iterations, single fork)
      *
      * Note the performance of the baseline, blank, and inline methods are the same.
      * dontinline differs a bit, because we are making the proper call.
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java	Mon Oct 07 14:50:30 2013 +0400
@@ -84,8 +84,8 @@
      * You can run this test with:
      *    $ mvn clean install
      *    $ java -jar target/microbenchmarks.jar ".*JMHSample_17.*" \
-     *        -i 20 -r 1s -wi 1 -t ${CPU*16} -si {true|false}
-     *    (we requested 1 warmup iterations, 20 iterations, 1 sec each,
+     *        -i 20 -wi 1 -f 1 -t ${CPU*16} -si {true|false}
+     *    (we requested 1 warmup iterations, 20 iterations, single fork,
      *     lots of threads, and changeable "synchronize iterations" option)
      *
      * Note the performance of -si false version is more flaky, even
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_18_Control.java	Mon Oct 07 14:50:30 2013 +0400
@@ -72,8 +72,8 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_18.*" -wi 1 -i 5 -r 1s -t 2
-     *    (we requested 1 warmup iterations, 5 iterations, 1 sec each, and two threads)
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_18.*" -wi 1 -i 5 -t 2 -f 1
+     *    (we requested 1 warmup iterations, 5 iterations, 2 threads, and single fork)
      */
 
 }
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java	Mon Oct 07 14:50:30 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.Measurement;
 import org.openjdk.jmh.annotations.OutputTimeUnit;
@@ -50,6 +51,7 @@
     @OutputTimeUnit(TimeUnit.SECONDS)
     @Warmup(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
     @Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
+    @Fork(1)
     public double measure() {
         return Math.log(x1);
     }
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java	Mon Oct 07 14:50:30 2013 +0400
@@ -113,7 +113,7 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_21.*" -w 1 -r 1 -i 5
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_21.*" -w 1 -i 5 -f 1
      *
      * Note the single token is just a few cycles, and the more tokens
      * you request, then more work is spent (almost linerarly)
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_22_FalseSharing.java	Mon Oct 07 14:50:07 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_22_FalseSharing.java	Mon Oct 07 14:50:30 2013 +0400
@@ -176,7 +176,7 @@
      *
      * You can run this test with:
      *    $ mvn clean install
-     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_22.*"
+     *    $ java -jar target/microbenchmarks.jar ".*JMHSample_22.*" -f 1
      *
      * Note the slowdowns.
      */