changeset 338:96d69d7ebcff

Annotation sample: make it clear that class-level annotation are also acceptable.
author shade
date Sat, 11 Jan 2014 01:51:00 +0400
parents 0ff1459dec27
children 6c1661cc20e8
files jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java	Sat Jan 11 00:38:53 2014 +0400
+++ b/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_20_Annotations.java	Sat Jan 11 01:51:00 2014 +0400
@@ -35,6 +35,8 @@
 import java.util.concurrent.TimeUnit;
 
 @State(Scope.Thread)
+@OutputTimeUnit(TimeUnit.MICROSECONDS)
+@Fork(1)
 public class JMHSample_20_Annotations {
 
     double x1 = Math.PI;
@@ -45,13 +47,17 @@
      * for the some of the benchmarks. This is very useful when you are
      * dealing with lots of microbenchmarks, and some of them require
      * special treatment.
+     *
+     * Annotation can also be placed on class, to have the effect over
+     * all the benchmark methods in the same class. The rule is, the
+     * annotation in the closest scope takes the precedence: i.e.
+     * the method-based annotation overrides class-based annotation,
+     * etc.
      */
 
     @GenerateMicroBenchmark
-    @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);
     }