changeset 73:538e773eb07b

jmh-samples: @GMB -> @BenchmarkMode
author shade
date Tue, 04 Jun 2013 13:40:17 +0400
parents 17dd93b91f6d
children ef0e8692fe0e
files jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkTypes.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_21_ConsumeCPU.java
diffstat 13 files changed, 189 insertions(+), 161 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_02_BenchmarkModes.java	Tue Jun 04 13:40:17 2013 +0400
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jmh.samples;
+
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.BenchmarkType;
+import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+
+import java.util.concurrent.TimeUnit;
+
+public class JMHSample_02_BenchmarkModes {
+
+    /*
+     * JMH generates lots of synthetic code for the microbenchmarks for
+     * you during the compilation. JMH can measure the methods in lots
+     * of modes, and it will generate all the needed code at once.
+     * Users may select the default benchmark mode with the special
+     * annotation, or select/override the mode via the command line.
+     *
+     * With this scenario, we start to measure something useful. Note
+     * that we can conveniently have the exception at the benchmark method,
+     * in order to reduce some of the clutter.
+     *
+     * P.S. It is helping at times to look into the generated code trying
+     * to diagnose  the performance issue. You might see you don't measuring
+     * it right! The generated code for this particular sample is somewhere at
+     *  target/generated-sources/annotations/.../JMHSample_02_BenchmarkModes.java
+     */
+
+    /*
+     * This benchmark type measures the raw throughput.
+     * We are using the special annotation to select the units to measure in,
+     * although you can use the default.
+     */
+
+    @OutputTimeUnit(TimeUnit.SECONDS)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.OpsPerTimeUnit)
+    public void measureThroughput() throws InterruptedException {
+        TimeUnit.MILLISECONDS.sleep(100);
+    }
+
+    /*
+     * This benchmark type measures the average execution time.
+     * Some might say it is the reciprocal throughput, and it really is.
+     * There are workloads where measuring times is more convenient though.
+     */
+
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.AverageTimePerOp)
+    public void measureAvgTime() throws InterruptedException {
+        TimeUnit.MILLISECONDS.sleep(100);
+    }
+
+    /*
+     * This benchmark type samples the execution time.
+     * With this benchmark, we are gathering the execution timings on their own,
+     * which allows us to infer the distributions, percentiles, etc.
+     *
+     * At this point, JMH only calculates percentile estimates.
+     *
+     * JMH also tries to auto-adjust sampling frequency: if the method
+     * is long enough, you will end up capturing all the samples.
+     */
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.SampleTimePerOp)
+    public void measureSamples() throws InterruptedException {
+        TimeUnit.MILLISECONDS.sleep(100);
+    }
+
+    /*
+     * This benchmark type measures the single method invocation time.
+     * This mode is useful to do cold startup tests, when you specifically
+     * do not want to call the benchmark method continuously.
+     */
+
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.SingleShotTime)
+    public void measureSingleShot() throws InterruptedException {
+        TimeUnit.MILLISECONDS.sleep(100);
+    }
+
+    /*
+     * HOW TO RUN THIS TEST:
+     *
+     * 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)
+     *
+     * 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_02_BenchmarkTypes.java	Tue Jun 04 13:29:12 2013 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/**
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.jmh.samples;
-
-import org.openjdk.jmh.annotations.BenchmarkType;
-import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-
-import java.util.concurrent.TimeUnit;
-
-public class JMHSample_02_BenchmarkTypes {
-
-    /*
-     * JMH generates lots of synthetic code for the microbenchmarks for
-     * you during the compilation. We can request different generation
-     * strategies, and measure different things.
-     *
-     * With this scenario, we start to measure something useful. Note
-     * that we can conveniently have the exception at the benchmark method,
-     * in order to reduce some of the clutter.
-     *
-     * P.S. It is helping at times to look into the generated code trying
-     * to diagnose  the performance issue. You might see you don't measuring
-     * it right! The generated code for this particular sample is somewhere at
-     *  target/generated-sources/annotations/.../JMHSample_02_BenchmarkTypes.java
-     */
-
-    /*
-     * This benchmark type measures the raw throughput.
-     * We are using the special annotation to select the units to measure in,
-     * although you can use the default.
-     */
-
-    @OutputTimeUnit(TimeUnit.SECONDS)
-    @GenerateMicroBenchmark(BenchmarkType.OpsPerTimeUnit)
-    public void measureThroughput() throws InterruptedException {
-        TimeUnit.MILLISECONDS.sleep(100);
-    }
-
-    /*
-     * This benchmark type measures the average execution time.
-     * Some might say it is the reciprocal throughput, and it really is.
-     * There are workloads where measuring times is more convenient though.
-     */
-
-    @OutputTimeUnit(TimeUnit.MICROSECONDS)
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
-    public void measureAvgTime() throws InterruptedException {
-        TimeUnit.MILLISECONDS.sleep(100);
-    }
-
-    /*
-     * This benchmark type samples the execution time.
-     * With this benchmark, we are gathering the execution timings on their own,
-     * which allows us to infer the distributions, percentiles, etc.
-     *
-     * At this point, JMH only calculates percentile estimates.
-     *
-     * JMH also tries to auto-adjust sampling frequency: if the method
-     * is long enough, you will end up capturing all the samples.
-     */
-    @OutputTimeUnit(TimeUnit.MICROSECONDS)
-    @GenerateMicroBenchmark(BenchmarkType.SampleTimePerOp)
-    public void measureSamples() throws InterruptedException {
-        TimeUnit.MILLISECONDS.sleep(100);
-    }
-
-    /*
-     * This benchmark type measures the single method invocation time.
-     * This mode is useful to do cold startup tests, when you specifically
-     * do not want to call the benchmark method continuously.
-     */
-
-    @OutputTimeUnit(TimeUnit.MICROSECONDS)
-    @GenerateMicroBenchmark(BenchmarkType.SingleShotTime)
-    public void measureSingleShot() throws InterruptedException {
-        TimeUnit.MILLISECONDS.sleep(100);
-    }
-
-    /*
-     * HOW TO RUN THIS TEST:
-     *
-     * 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)
-     *
-     * 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_07_FixtureLevelInvocation.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_07_FixtureLevelInvocation.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.Level;
@@ -103,12 +104,14 @@
      * when we are sleeping.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.AverageTimePerOp)
     public double measureHot(NormalState e, final Scratch s) throws ExecutionException, InterruptedException {
         return e.service.submit(new Task(s)).get();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
+    @BenchmarkMode(BenchmarkType.AverageTimePerOp)
     public double measureCold(LaggingState e, final Scratch s) throws ExecutionException, InterruptedException {
         return e.service.submit(new Task(s)).get();
     }
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_08_DeadCode.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.OutputTimeUnit;
@@ -33,6 +34,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_08_DeadCode {
 
@@ -48,18 +50,18 @@
 
     private double x = Math.PI;
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void baseline() {
         // do nothing, this is a baseline
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void measureWrong() {
         // This is wrong: result is not used, and the entire computation is optimized out.
         Math.log(x);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double measureRight() {
         // This is correct: the result is being used.
         return Math.log(x);
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_09_Blackholes.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.OutputTimeUnit;
@@ -33,6 +34,7 @@
 
 import java.util.concurrent.TimeUnit;
 
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 @State(Scope.Thread)
 public class JMHSample_09_Blackholes {
@@ -48,7 +50,7 @@
      * Baseline measurement: how much single Math.log costs.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double baseline() {
         return Math.log(x1);
     }
@@ -58,7 +60,7 @@
      * is redundant and optimized out.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double measureWrong() {
         Math.log(x1);
         return Math.log(x2);
@@ -72,7 +74,7 @@
      * the results does not offset the results much.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double measureRight_1() {
         return Math.log(x1) + Math.log(x2);
     }
@@ -86,7 +88,7 @@
      * bundled with JMH).
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void measureRight_2(BlackHole bh1, BlackHole bh2) {
         bh1.consume(Math.log(x1));
         bh2.consume(Math.log(x2));
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.OutputTimeUnit;
@@ -33,6 +34,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_10_ConstantFold {
 
@@ -50,18 +52,18 @@
     // IDEs will say "Oh, you can convert this field to local variable". Don't. Trust. Them.
     private double x = Math.PI;
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void baseline() {
         // do nothing, this is a baseline
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double measureWrong() {
         // This is wrong: the result is provably the same, optimized out.
         return Math.log(Math.PI);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public double measureRight() {
         // This is correct: the result is being used.
         return Math.log(x);
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_11_Loops.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.OperationsPerInvocation;
@@ -34,6 +35,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_11_Loops {
 
@@ -58,7 +60,7 @@
      * This is what you do with JMH.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public int measureRight() {
         return (x + y);
     }
@@ -81,37 +83,37 @@
      * to get the individual operation cost.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(1)
     public int measureWrong_1() {
         return reps(1);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(10)
     public int measureWrong_10() {
         return reps(10);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(100)
     public int measureWrong_100() {
         return reps(100);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(1000)
     public int measureWrong_1000() {
         return reps(1000);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(10000)
     public int measureWrong_10000() {
         return reps(10000);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @OperationsPerInvocation(100000)
     public int measureWrong_100000() {
         return reps(100000);
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_12_Forking.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
@@ -34,6 +35,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_12_Forking {
 
@@ -97,7 +99,7 @@
      * Fork(0) helps to run in the same JVM.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(0)
     public int measure_1_c1() {
         return measure(c1);
@@ -107,7 +109,7 @@
      * Then Counter2...
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(0)
     public int measure_2_c2() {
         return measure(c2);
@@ -117,7 +119,7 @@
      * Then Counter1 again...
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(0)
     public int measure_3_c1_again() {
         return measure(c1);
@@ -133,7 +135,7 @@
      * This is the test for Counter1.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(1)
     public int measure_4_forked_c1() {
         return measure(c1);
@@ -143,7 +145,7 @@
      * ...and this is the test for Counter2.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(1)
     public int measure_5_forked_c2() {
         return measure(c2);
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_13_RunToRun.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.Fork;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
@@ -35,6 +36,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.MILLISECONDS)
 public class JMHSample_13_RunToRun {
 
@@ -68,19 +70,19 @@
      * Now, we will run this different number of times.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(1)
     public void baseline(SleepyState s) throws InterruptedException {
         TimeUnit.MILLISECONDS.sleep(s.sleepTime);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(5)
     public void fork_1(SleepyState s) throws InterruptedException {
         TimeUnit.MILLISECONDS.sleep(s.sleepTime);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Fork(20)
     public void fork_2(SleepyState s) throws InterruptedException {
         TimeUnit.MILLISECONDS.sleep(s.sleepTime);
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_15_Asymmetric.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.Group;
@@ -37,6 +38,7 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 @State(Scope.Group)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_15_Asymmetric {
 
@@ -70,14 +72,14 @@
         counter = new AtomicInteger();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Group("g")
     @Threads(3)
     public int inc() {
         return counter.incrementAndGet();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     @Group("g")
     public int get() {
         return counter.get();
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_16_CompilerControl.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.CompilerControl;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
@@ -34,6 +35,7 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_16_CompilerControl {
 
@@ -76,27 +78,27 @@
      * These method measures the calls performance.
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void baseline() {
         // this method was intentionally left blank
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void blank() {
         target_blank();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void dontinline() {
         target_dontInline();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void inline() {
         target_inline();
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void exclude() {
         target_exclude();
     }
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_17_SyncIterations.java	Tue Jun 04 13:40:17 2013 +0400
@@ -44,7 +44,7 @@
 
     private double src;
 
-    @GenerateMicroBenchmark(BenchmarkType.OpsPerTimeUnit)
+    @GenerateMicroBenchmark
     public double test() {
         double s = src;
         for (int i = 0; i < 1000; i++) {
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java	Tue Jun 04 13:29:12 2013 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_21_ConsumeCPU.java	Tue Jun 04 13:40:17 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.samples;
 
+import org.openjdk.jmh.annotations.BenchmarkMode;
 import org.openjdk.jmh.annotations.BenchmarkType;
 import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.OutputTimeUnit;
@@ -31,6 +32,7 @@
 
 import java.util.concurrent.TimeUnit;
 
+@BenchmarkMode(BenchmarkType.AverageTimePerOp)
 @OutputTimeUnit(TimeUnit.NANOSECONDS)
 public class JMHSample_21_ConsumeCPU {
 
@@ -46,62 +48,62 @@
      * within the testing code, and propagating blackholes is tedious).
      */
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0000() {
         BlackHole.consumeCPU(0);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0001() {
         BlackHole.consumeCPU(1);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0002() {
         BlackHole.consumeCPU(2);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0004() {
         BlackHole.consumeCPU(4);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0008() {
         BlackHole.consumeCPU(8);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0016() {
         BlackHole.consumeCPU(16);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0032() {
         BlackHole.consumeCPU(32);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0064() {
         BlackHole.consumeCPU(64);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0128() {
         BlackHole.consumeCPU(128);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0256() {
         BlackHole.consumeCPU(256);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_0512() {
         BlackHole.consumeCPU(512);
     }
 
-    @GenerateMicroBenchmark(BenchmarkType.AverageTimePerOp)
+    @GenerateMicroBenchmark
     public void consume_1024() {
         BlackHole.consumeCPU(1024);
     }