changeset 321:5f79c18b487d

Control objects should be treated in all methods in the @Group.
author shade
date Thu, 12 Dec 2013 22:17:54 +0400
parents 9c392e4cd432
children 8224248c8e02
files jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/ControlTest.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java
diffstat 2 files changed, 128 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/compile/ControlTest.java	Thu Dec 12 22:17:54 2013 +0400
@@ -0,0 +1,122 @@
+/*
+ * 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.it.compile;
+
+import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
+import org.openjdk.jmh.annotations.Group;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.logic.Control;
+
+public class ControlTest {
+
+    @State(Scope.Benchmark)
+    public static class BenchmarkState {
+
+    }
+
+    @State(Scope.Thread)
+    public static class ThreadState {
+
+    }
+
+    @State(Scope.Group)
+    public static class GroupState {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("plain")
+    public void plain_test1(Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("plain")
+    public void plain_test2(Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("plain")
+    public void plain_test3() {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("bench")
+    public void bench_test1(BenchmarkState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("bench")
+    public void bench_test2(BenchmarkState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("bench")
+    public void bench_test3(BenchmarkState s) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("thread")
+    public void thread_test1(ThreadState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("thread")
+    public void thread_test2(ThreadState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("thread")
+    public void thread_test3(ThreadState s) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("group")
+    public void group_test1(GroupState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("group")
+    public void group_test2(GroupState s, Control cnt) {
+
+    }
+
+    @GenerateMicroBenchmark
+    @Group("group")
+    public void group_test3(GroupState s) {
+
+    }
+
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Fri Dec 06 19:14:03 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/StateObjectHandler.java	Thu Dec 12 22:17:54 2013 +0400
@@ -240,22 +240,17 @@
         return sb.toString();
     }
 
-    public static Collection<StateObject> cons(Collection<StateObject> l1) {
+    public static Collection<StateObject> cons(Collection<StateObject>... colls) {
         SortedSet<StateObject> r = new TreeSet<StateObject>(StateObject.ID_COMPARATOR);
-        r.addAll(l1);
-        return r;
-    }
-
-    public static Collection<StateObject> cons(Collection<StateObject> l1, Collection<StateObject> l2) {
-        SortedSet<StateObject> r = new TreeSet<StateObject>(StateObject.ID_COMPARATOR);
-        r.addAll(l1);
-        r.addAll(l2);
+        for (Collection<StateObject> coll : colls) {
+            r.addAll(coll);
+        }
         return r;
     }
 
     public Collection<String> getHelperBlock(String method, Level helperLevel, HelperType type) {
 
-        Collection<StateObject> states = cons(args.get(method), implicits.values());
+        Collection<StateObject> states = cons(args.get(method), implicits.values(), getControls());
 
         // Look for the offending methods.
         // This will be used to skip the irrelevant blocks for state objects down the stream.
@@ -442,7 +437,7 @@
 
     public List<String> getStateGetters(Element method) {
         List<String> result = new ArrayList<String>();
-        for (StateObject so : cons(args.get(method.getSimpleName().toString()), implicits.values())) {
+        for (StateObject so : cons(args.get(method.getSimpleName().toString()), implicits.values(), getControls())) {
             switch (so.scope) {
                 case Benchmark:
                 case Thread: