changeset 1435:335dfeac13dc

7902085: hs_* profilers regression: typo in getInternalRuntimeCounter, should be getInternalTYPECounter
author shade
date Wed, 20 Dec 2017 20:47:59 +0100
parents 1ddf31f810a3
children fbe1b55eadf8
files jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/AbstractHotspotProfilerTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java
diffstat 12 files changed, 324 insertions(+), 7 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/profilers/AbstractHotspotProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import org.openjdk.jmh.annotations.*;
+
+import java.util.concurrent.TimeUnit;
+
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(1) // 0 to enable debugging
+@Warmup(iterations = 5)
+@Measurement(iterations = 5, time = 100, timeUnit = TimeUnit.MILLISECONDS)
+@BenchmarkMode(Mode.AverageTime)
+public class AbstractHotspotProfilerTest {
+
+    @Benchmark
+    public Object alloc() {
+        return new Object();
+    }
+
+    boolean isHotspotVM() {
+        String name = System.getProperty("java.vm.name");
+        return (name.contains("OpenJDK") || name.contains("HotSpot"));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotClassloadingProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.profile.HotspotClassloadingProfiler;
+import org.openjdk.jmh.profile.ProfilerException;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class HotspotClassloadingProfilerTest extends AbstractHotspotProfilerTest {
+
+    @Test
+    public void test() throws RunnerException {
+        try {
+            new HotspotClassloadingProfiler();
+        } catch (ProfilerException e) {
+            Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM());
+            return;
+        }
+        Options opts = new OptionsBuilder()
+                .include(Fixtures.getTestMask(this.getClass()))
+                .addProfiler(HotspotClassloadingProfiler.class)
+                .build();
+        new Runner(opts).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotCompilationProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.profile.HotspotClassloadingProfiler;
+import org.openjdk.jmh.profile.HotspotCompilationProfiler;
+import org.openjdk.jmh.profile.ProfilerException;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class HotspotCompilationProfilerTest extends AbstractHotspotProfilerTest {
+
+    @Test
+    public void test() throws RunnerException {
+        try {
+            new HotspotCompilationProfiler();
+        } catch (ProfilerException e) {
+            Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM());
+            return;
+        }
+        Options opts = new OptionsBuilder()
+                .include(Fixtures.getTestMask(this.getClass()))
+                .addProfiler(HotspotCompilationProfiler.class)
+                .build();
+        new Runner(opts).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotMemoryProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.profile.HotspotCompilationProfiler;
+import org.openjdk.jmh.profile.HotspotMemoryProfiler;
+import org.openjdk.jmh.profile.ProfilerException;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class HotspotMemoryProfilerTest extends AbstractHotspotProfilerTest {
+
+    @Test
+    public void test() throws RunnerException {
+        try {
+            new HotspotMemoryProfiler();
+        } catch (ProfilerException e) {
+            Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM());
+            return;
+        }
+        Options opts = new OptionsBuilder()
+                .include(Fixtures.getTestMask(this.getClass()))
+                .addProfiler(HotspotMemoryProfiler.class)
+                .build();
+        new Runner(opts).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotRuntimeProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.profile.HotspotMemoryProfiler;
+import org.openjdk.jmh.profile.HotspotRuntimeProfiler;
+import org.openjdk.jmh.profile.ProfilerException;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class HotspotRuntimeProfilerTest extends AbstractHotspotProfilerTest {
+
+    @Test
+    public void test() throws RunnerException {
+        try {
+            new HotspotRuntimeProfiler();
+        } catch (ProfilerException e) {
+            Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM());
+            return;
+        }
+        Options opts = new OptionsBuilder()
+                .include(Fixtures.getTestMask(this.getClass()))
+                .addProfiler(HotspotRuntimeProfiler.class)
+                .build();
+        new Runner(opts).run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/HotspotThreadProfilerTest.java	Wed Dec 20 20:47:59 2017 +0100
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 2015, 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.profilers;
+
+import junit.framework.Assert;
+import org.junit.Test;
+import org.openjdk.jmh.it.Fixtures;
+import org.openjdk.jmh.profile.HotspotRuntimeProfiler;
+import org.openjdk.jmh.profile.HotspotThreadProfiler;
+import org.openjdk.jmh.profile.ProfilerException;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.RunnerException;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+public class HotspotThreadProfilerTest extends AbstractHotspotProfilerTest {
+
+    @Test
+    public void test() throws RunnerException {
+        try {
+            new HotspotThreadProfiler();
+        } catch (ProfilerException e) {
+            Assert.assertFalse("HotSpot VMs should support this profiler", isHotspotVM());
+            return;
+        }
+        Options opts = new OptionsBuilder()
+                .include(Fixtures.getTestMask(this.getClass()))
+                .addProfiler(HotspotThreadProfiler.class)
+                .build();
+        new Runner(opts).run();
+    }
+}
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/AbstractHotspotProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -39,11 +39,11 @@
 
     private Map<String, Long> prevs;
 
-    public AbstractHotspotProfiler(String beanName) throws ProfilerException {
+    public AbstractHotspotProfiler(String beanName, String methodName) throws ProfilerException {
         try {
             Class<?> helper = Class.forName("sun.management.ManagementFactoryHelper");
             bean = helper.getMethod("get" + beanName).invoke(null);
-            getListMethod = bean.getClass().getMethod("getInternalRuntimeCounters");
+            getListMethod = bean.getClass().getMethod(methodName);
             getListMethod.setAccessible(true);
             getListMethod.invoke(bean); // try
         } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotClassloadingProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -27,7 +27,7 @@
 public class HotspotClassloadingProfiler extends AbstractHotspotProfiler {
 
     public HotspotClassloadingProfiler() throws ProfilerException {
-        super("HotspotClassLoadingMBean");
+        super("HotspotClassLoadingMBean", "getInternalClassLoadingCounters");
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotCompilationProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -36,7 +36,7 @@
 public class HotspotCompilationProfiler extends AbstractHotspotProfiler {
 
     public HotspotCompilationProfiler() throws ProfilerException {
-        super("HotspotCompilationMBean");
+        super("HotspotCompilationMBean", "getInternalCompilerCounters");
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotMemoryProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -27,7 +27,7 @@
 public class HotspotMemoryProfiler extends AbstractHotspotProfiler {
 
     public HotspotMemoryProfiler() throws ProfilerException {
-        super("HotspotMemoryMBean");
+        super("HotspotMemoryMBean", "getInternalMemoryCounters");
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotRuntimeProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -36,7 +36,7 @@
 public class HotspotRuntimeProfiler extends AbstractHotspotProfiler {
 
     public HotspotRuntimeProfiler() throws ProfilerException {
-        super("HotspotRuntimeMBean");
+        super("HotspotRuntimeMBean", "getInternalRuntimeCounters");
     }
 
     @Override
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java	Fri Sep 22 18:11:47 2017 +0200
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/HotspotThreadProfiler.java	Wed Dec 20 20:47:59 2017 +0100
@@ -35,7 +35,7 @@
 public class HotspotThreadProfiler extends AbstractHotspotProfiler {
 
     public HotspotThreadProfiler() throws ProfilerException {
-        super("HotspotThreadMBean");
+        super("HotspotThreadMBean", "getInternalThreadingCounters");
     }
 
     @Override