changeset 81:e82505a6179a

Re-introduce BenchmarkType for backward compatibility.
author shade
date Wed, 05 Jun 2013 16:04:00 +0400
parents d0a438249900
children a28a02c330d1
files jmh-core/src/main/java/org/openjdk/jmh/annotations/BenchmarkType.java jmh-core/src/main/java/org/openjdk/jmh/annotations/GenerateMicroBenchmark.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java
diffstat 3 files changed, 86 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/BenchmarkType.java	Wed Jun 05 16:04:00 2013 +0400
@@ -0,0 +1,55 @@
+/**
+ * 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.annotations;
+
+/**
+ * This enum is deprecated, use {@link Mode} instead.
+ */
+@Deprecated
+public enum BenchmarkType {
+    /**
+     * Operations per unit of time,
+     * {@link org.openjdk.jmh.logic.results.OpsPerTimeUnit}.
+     */
+    OpsPerTimeUnit,
+
+    /**
+     * Average time per operation
+     * {@link org.openjdk.jmh.logic.results.AverageTimePerOp}.
+     */
+    AverageTimePerOp,
+
+    /**
+     * Time distribution, percentile estimation
+     * {@link org.openjdk.jmh.logic.results.SampleTimePerOp}.
+     */
+    SampleTimePerOp,
+
+    /**
+     * Time the single execution
+     * {@link org.openjdk.jmh.logic.results.SingleShotTime}.
+     */
+    SingleShotTime,
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/annotations/GenerateMicroBenchmark.java	Tue Jun 04 15:12:48 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/annotations/GenerateMicroBenchmark.java	Wed Jun 05 16:04:00 2013 +0400
@@ -78,4 +78,12 @@
 @Retention(RetentionPolicy.SOURCE)
 public @interface GenerateMicroBenchmark {
 
+    /**
+     * This value is deprecated.
+     * Use {@link BenchmarkMode} instead.
+     */
+    @Deprecated
+    public BenchmarkType[] value() default { BenchmarkType.OpsPerTimeUnit };
+
+
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Tue Jun 04 15:12:48 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Wed Jun 05 16:04:00 2013 +0400
@@ -201,6 +201,29 @@
                 result.put(groupName, group);
             }
 
+            // backward compatibility
+            GenerateMicroBenchmark gmb = method.getAnnotation(GenerateMicroBenchmark.class);
+            if (!Arrays.deepEquals(gmb.value(), new BenchmarkType[] { BenchmarkType.OpsPerTimeUnit })) {
+                for (BenchmarkType t : gmb.value()) {
+                    switch (t) {
+                        case AverageTimePerOp:
+                            group.addModes(Mode.AverageTime);
+                            break;
+                        case OpsPerTimeUnit:
+                            group.addModes(Mode.Throughput);
+                            break;
+                        case SampleTimePerOp:
+                            group.addModes(Mode.SampleTime);
+                            break;
+                        case SingleShotTime:
+                            group.addModes(Mode.SingleShotTime);
+                            break;
+                        default:
+                            throw new IllegalStateException("Unknown BenchmarkType: " + t);
+                    }
+                }
+            }
+
             BenchmarkMode mbAn = method.getAnnotation(BenchmarkMode.class);
             if (mbAn != null) {
                 group.addModes(mbAn.value());