Search in sources :

Example 11 with CompilationMXBean

use of java.lang.management.CompilationMXBean in project MyPerf4J by ThinkpadNC5.

the class CompilationTest method test.

@Test
public void test() {
    CompilationMXBean mxBean = ManagementFactory.getCompilationMXBean();
    System.out.println(mxBean.getName());
    System.out.println(mxBean.getObjectName());
    System.out.println(mxBean.getTotalCompilationTime() + "ms");
}
Also used : CompilationMXBean(java.lang.management.CompilationMXBean) Test(org.junit.Test)

Example 12 with CompilationMXBean

use of java.lang.management.CompilationMXBean in project jdk8u_jdk by JetBrains.

the class MXBeanInteropTest1 method doCompilationMXBeanTest.

private final int doCompilationMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0;
    System.out.println("---- CompilationMXBean");
    try {
        ObjectName compilationName = new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
        if (mbsc.isRegistered(compilationName)) {
            MBeanInfo mbInfo = mbsc.getMBeanInfo(compilationName);
            errorCount += checkNonEmpty(mbInfo);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            CompilationMXBean compilation = null;
            compilation = JMX.newMXBeanProxy(mbsc, compilationName, CompilationMXBean.class);
            System.out.println("getName\t\t" + compilation.getName());
            boolean supported = compilation.isCompilationTimeMonitoringSupported();
            System.out.println("isCompilationTimeMonitoringSupported\t\t" + supported);
            if (supported) {
                System.out.println("getTotalCompilationTime\t\t" + compilation.getTotalCompilationTime());
            }
        }
        System.out.println("---- OK\n");
    } catch (Exception e) {
        Utils.printThrowable(e, true);
        errorCount++;
        System.out.println("---- ERROR\n");
    }
    return errorCount;
}
Also used : MBeanInfo(javax.management.MBeanInfo) CompilationMXBean(java.lang.management.CompilationMXBean) ObjectName(javax.management.ObjectName)

Example 13 with CompilationMXBean

use of java.lang.management.CompilationMXBean in project openj9 by eclipse.

the class TestManagementFactory method testCompilationMXBeanProxy.

@Test
public void testCompilationMXBeanProxy() {
    try {
        CompilationMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(ManagementFactory.getPlatformMBeanServer(), "java.lang:type=Compilation", CompilationMXBean.class);
        AssertJUnit.assertNotNull(proxy);
        AssertJUnit.assertNotNull(proxy.toString());
        AssertJUnit.assertEquals("java.lang:type=Compilation", proxy.getObjectName().toString());
        AssertJUnit.assertEquals(proxy.getName(), ManagementFactory.getCompilationMXBean().getName());
        AssertJUnit.assertEquals(proxy.isCompilationTimeMonitoringSupported(), ManagementFactory.getCompilationMXBean().isCompilationTimeMonitoringSupported());
        if (!proxy.isCompilationTimeMonitoringSupported()) {
            try {
                long tct = proxy.getTotalCompilationTime();
                Assert.fail("Should have thrown unsupported operation exception!");
            } catch (UnsupportedOperationException t) {
                logger.debug("UnsupportedOperationException occurred, as expected: " + t.getMessage());
            }
        }
    } catch (IOException e) {
        Assert.fail("Unexpected IOException : " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : CompilationMXBean(java.lang.management.CompilationMXBean) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Aggregations

CompilationMXBean (java.lang.management.CompilationMXBean)13 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 Test (org.testng.annotations.Test)2 JvmCompilationMetrics (cn.myperf4j.base.metric.JvmCompilationMetrics)1 IOException (java.io.IOException)1 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 MBeanInfo (javax.management.MBeanInfo)1 ObjectName (javax.management.ObjectName)1 Mutation (org.apache.accumulo.core.data.Mutation)1 TMutation (org.apache.accumulo.core.data.thrift.TMutation)1 Test (org.junit.Test)1