changeset 115:7c137a6d33e4

Completely deprecate @MicroBenchmark. JMH will report uses as errors.
author shade
date Fri, 16 Aug 2013 18:12:35 +0400
parents 810907f82c45
children e5450f2db884
files jmh-core/src/main/java/org/openjdk/jmh/annotations/MicroBenchmark.java jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/MicroBenchmarkProcessor.java jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java
diffstat 7 files changed, 19 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/MicroBenchmark.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/MicroBenchmark.java	Fri Aug 16 18:12:35 2013 +0400
@@ -42,6 +42,7 @@
  */
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
+@Deprecated
 public @interface MicroBenchmark {
 
     /**
--- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/Mode.java	Fri Aug 16 18:12:35 2013 +0400
@@ -65,12 +65,6 @@
      */
     All("all", "TEST MODE"),
 
-    /**
-     * Legacy mode: don't use directly.
-     * This is used notably to support legacy {@link MicroBenchmark} annotation.
-     */
-    Legacy("legacy", "Legacy mode")
-
     ;
     private final String shortLabel;
     private final String longLabel;
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Fri Aug 16 18:12:35 2013 +0400
@@ -130,11 +130,6 @@
                         }
                     }
 
-                    // hack: collect @Microbenchmarks as well
-                    for (String bench : MicroBenchmarkProcessor.COLLECTED_MICROBENCHMARKS) {
-                        writer.println(bench + ", " + bench + ", " + Mode.Legacy);
-                    }
-
                     writer.close();
                 } catch (IOException ex) {
                     processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing MicroBenchmark list " + ex);
@@ -508,8 +503,6 @@
      * @param methodGroup
      */
     private void generateMethod(Mode benchmarkKind, PrintWriter writer, MethodGroup methodGroup, StateObjectHandler states) {
-        if (benchmarkKind == Mode.Legacy) return;
-
         writer.println();
         for (String ann : generateMethodAnnotations(methodGroup)) {
             writer.println("    " + ann);
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/MicroBenchmarkProcessor.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/MicroBenchmarkProcessor.java	Fri Aug 16 18:12:35 2013 +0400
@@ -24,6 +24,7 @@
  */
 package org.openjdk.jmh.processor.internal;
 
+import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
 import org.openjdk.jmh.annotations.MicroBenchmark;
 
 import javax.annotation.processing.AbstractProcessor;
@@ -41,8 +42,6 @@
 @SupportedSourceVersion(SourceVersion.RELEASE_6)
 public class MicroBenchmarkProcessor extends AbstractProcessor {
 
-    public static final Set<String> COLLECTED_MICROBENCHMARKS = new HashSet<String>();
-
     @Override
     public Set<String> getSupportedAnnotationTypes() {
         return Collections.singleton(MicroBenchmark.class.getName());
@@ -60,12 +59,11 @@
                 // Still processing add all annotated methods to the set
                 for (TypeElement annotation : annotations) {
                     for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
-                        processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING,
+                        processingEnv.getMessager().printMessage(Kind.ERROR,
                                 "The " + MicroBenchmark.class.getSimpleName()
-                                        + " is detected. This is not the supported API anymore. \n"
+                                        + " annotation is detected. This is not the supported API anymore. \n"
+                                        + "Please migrate to @" + GenerateMicroBenchmark.class.getSimpleName() + ".\n"
                                         + element.getEnclosingElement() + '.' + element.toString());
-                        TypeElement klass = (TypeElement) element.getEnclosingElement();
-                        COLLECTED_MICROBENCHMARKS.add(klass.getQualifiedName().toString() + "." + element.getSimpleName().toString());
                     }
                 }
             }
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/BenchmarkRecord.java	Fri Aug 16 18:12:35 2013 +0400
@@ -91,11 +91,7 @@
     }
 
     public String generatedTarget(Mode type) {
-        if (mode != Mode.Legacy) {
-            return generatedName + "_" + type;
-        } else {
-            return generatedName;
-        }
+        return generatedName + "_" + type;
     }
 
     public String generatedTarget() {
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/LoopMicroBenchmarkHandler.java	Fri Aug 16 18:12:35 2013 +0400
@@ -107,24 +107,21 @@
             resultList.add(executor.submit(runner));
         }
 
-        // legacy mode has no knowledge about setup/teardown barriers
-        if (mode != Mode.Legacy) {
-            // wait for all threads to start executing
-            try {
-                preSetupBarrier.await();
-            } catch (InterruptedException ex) {
-                log(ex);
-            }
-            startProfilers();
+        // wait for all threads to start executing
+        try {
+            preSetupBarrier.await();
+        } catch (InterruptedException ex) {
+            log(ex);
+        }
+        startProfilers();
 
-            // wait for all threads to stop executing
-            try {
-                preTearDownBarrier.await();
-            } catch (InterruptedException ex) {
-                log(ex);
-            }
-            stopProfilers(iterationResults);
+        // wait for all threads to stop executing
+        try {
+            preTearDownBarrier.await();
+        } catch (InterruptedException ex) {
+            log(ex);
         }
+        stopProfilers(iterationResults);
 
         // wait for the result, continuously polling the worker threads.
         //
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Aug 16 17:52:13 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/Runner.java	Fri Aug 16 18:12:35 2013 +0400
@@ -176,7 +176,6 @@
             if (br.getMode() == Mode.All) {
                 for (Mode mode : Mode.values()) {
                     if (mode == Mode.All) continue;
-                    if (mode == Mode.Legacy) continue;
                     newBenchmarks.add(br.cloneWith(mode));
                 }
             } else {