Java Code Examples for java.lang.management.CompilationMXBean

The following are top voted examples for showing how to use java.lang.management.CompilationMXBean. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: swage   File: CompilationTimeSensor.java   View source code 6 votes vote down vote up
@Override
public void sense(final MetricRecorder.Context metricContext)
{
    CompilationMXBean mxBean = ManagementFactory.getCompilationMXBean();

    // Compilation time may not be supported on some platforms, skip if so.
    if (!mxBean.isCompilationTimeMonitoringSupported()) {
        return;
    }

    long total = mxBean.getTotalCompilationTime();
    metricContext.record(TOTAL_COMPILATION_TIME, total, Unit.MILLISECOND);
    metricContext.record(COMPILATION_TIME, total - prevTotal, Unit.MILLISECOND);

    this.prevTotal = total;
}
 
Example 2
Project: javify   File: TestCompilation.java   View source code 6 votes vote down vote up
public static void main(String[] args)
{
  CompilationMXBean bean = ManagementFactory.getCompilationMXBean();
  if (bean == null)
    {
      System.out.println("The compilation bean is not supported by this VM.");
      System.exit(-1);
    }
  System.out.println("Bean: " + bean);
  System.out.println("JIT compiler name: " + bean.getName());
  boolean timeMonitoring = bean.isCompilationTimeMonitoringSupported();
  System.out.println("Compilation time monitoring supported: " + timeMonitoring);
  if (timeMonitoring)
    {
      System.out.println("Compilation time: "
                         + bean.getTotalCompilationTime() + "ms");
    }
}
 
Example 3
Project: jvm-stm   File: TestCompilation.java   View source code 6 votes vote down vote up
public static void main(String[] args)
 {
   CompilationMXBean bean = ManagementFactory.getCompilationMXBean();
   if (bean == null)
     {
System.out.println("The compilation bean is not supported by this VM.");
System.exit(-1);
     }
   System.out.println("Bean: " + bean);
   System.out.println("JIT compiler name: " + bean.getName());
   boolean timeMonitoring = bean.isCompilationTimeMonitoringSupported();
   System.out.println("Compilation time monitoring supported: " + timeMonitoring);
   if (timeMonitoring)
     {
System.out.println("Compilation time: "
		   + bean.getTotalCompilationTime() + "ms");
     }
 }
 
Example 4
Project: astor   File: JvmMetrics.java   View source code 6 votes vote down vote up
private static void writeJitMetrics(
    PrintStream out, boolean verbose, boolean pretty) {

  CompilationMXBean cBean = ManagementFactory.getCompilationMXBean();

  String name;
  if (verbose) {
    name = cBean.getName();
  } else {
    name = "total";
  }

  if (pretty) {
    out.println("\nJIT Stats");
    out.println(String.format(
        "\t%s jit time: %d ms", name, cBean.getTotalCompilationTime()));
  } else {
    out.println(normalizeTabularColonPos(String.format("%s-jit-time-ms : %d",
        normalizeName(name), cBean.getTotalCompilationTime())));
  }
}
 
Example 5
Project: closure-compiler   File: JvmMetrics.java   View source code 6 votes vote down vote up
private static void writeJitMetrics(
    PrintStream out, boolean verbose, boolean pretty) {

  CompilationMXBean cBean = ManagementFactory.getCompilationMXBean();

  String name;
  if (verbose) {
    name = cBean.getName();
  } else {
    name = "total";
  }

  if (pretty) {
    out.println("\nJIT Stats");
    out.printf("\t%s jit time: %d ms%n", name, cBean.getTotalCompilationTime());
  } else {
    out.println(normalizeTabularColonPos(String.format("%s-jit-time-ms : %d",
        normalizeName(name), cBean.getTotalCompilationTime())));
  }
}
 
Example 6
Project: cn1   File: ManagementUtils.java   View source code 6 votes vote down vote up
/**
 * Creates the metadata for the
 * {@link java.lang.management.CompilationMXBean}. For this type of
 * platform bean the metadata covers :
 * <ul>
 * <li>3 attributes
 * <li>0 constructors
 * <li>0 operations
 * <li>0 notifications
 * </ul>
 * 
 * @param result
 */
private static void addCompilationBeanInfo(HashMap<String, MBeanInfo> result) {
    // Attributes
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[3];
    attributes[0] = new MBeanAttributeInfo("Name", String.class.getName(),
            "Name", true, false, false);
    attributes[1] = new MBeanAttributeInfo("TotalCompilationTime",
            Long.TYPE.getName(), "TotalCompilationTime", true, false, false);
    attributes[2] = new MBeanAttributeInfo(
            "CompilationTimeMonitoringSupported", Boolean.TYPE.getName(),
            "CompilationTimeMonitoringSupported", true, false, true);
    result.put(CompilationMXBean.class.getName(), new MBeanInfo(
            CompilationMXBeanImpl.class.getName(),
            CompilationMXBeanImpl.class.getName(), attributes, null, null,
            null));
}
 
Example 7
Project: JamVM-PH   File: TestCompilation.java   View source code 6 votes vote down vote up
public static void main(String[] args)
 {
   CompilationMXBean bean = ManagementFactory.getCompilationMXBean();
   if (bean == null)
     {
System.out.println("The compilation bean is not supported by this VM.");
System.exit(-1);
     }
   System.out.println("Bean: " + bean);
   System.out.println("JIT compiler name: " + bean.getName());
   boolean timeMonitoring = bean.isCompilationTimeMonitoringSupported();
   System.out.println("Compilation time monitoring supported: " + timeMonitoring);
   if (timeMonitoring)
     {
System.out.println("Compilation time: "
		   + bean.getTotalCompilationTime() + "ms");
     }
 }
 
Example 8
Project: classpath   File: TestCompilation.java   View source code 6 votes vote down vote up
public static void main(String[] args)
{
  CompilationMXBean bean = ManagementFactory.getCompilationMXBean();
  if (bean == null)
    {
      System.out.println("The compilation bean is not supported by this VM.");
      System.exit(-1);
    }
  System.out.println("Bean: " + bean);
  System.out.println("JIT compiler name: " + bean.getName());
  boolean timeMonitoring = bean.isCompilationTimeMonitoringSupported();
  System.out.println("Compilation time monitoring supported: " + timeMonitoring);
  if (timeMonitoring)
    {
      System.out.println("Compilation time: "
                         + bean.getTotalCompilationTime() + "ms");
    }
}
 
Example 9
Project: freeVM   File: ManagementUtils.java   View source code 6 votes vote down vote up
/**
 * Creates the metadata for the
 * {@link java.lang.management.CompilationMXBean}. For this type of
 * platform bean the metadata covers :
 * <ul>
 * <li>3 attributes
 * <li>0 constructors
 * <li>0 operations
 * <li>0 notifications
 * </ul>
 * 
 * @param result
 */
private static void addCompilationBeanInfo(HashMap<String, MBeanInfo> result) {
    // Attributes
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[3];
    attributes[0] = new MBeanAttributeInfo("Name", String.class.getName(),
            "Name", true, false, false);
    attributes[1] = new MBeanAttributeInfo("TotalCompilationTime",
            Long.TYPE.getName(), "TotalCompilationTime", true, false, false);
    attributes[2] = new MBeanAttributeInfo(
            "CompilationTimeMonitoringSupported", Boolean.TYPE.getName(),
            "CompilationTimeMonitoringSupported", true, false, true);
    result.put(CompilationMXBean.class.getName(), new MBeanInfo(
            CompilationMXBeanImpl.class.getName(),
            CompilationMXBeanImpl.class.getName(), attributes, null, null,
            null));
}
 
Example 10
Project: freeVM   File: ManagementUtils.java   View source code 6 votes vote down vote up
/**
 * Creates the metadata for the
 * {@link java.lang.management.CompilationMXBean}. For this type of
 * platform bean the metadata covers :
 * <ul>
 * <li>3 attributes
 * <li>0 constructors
 * <li>0 operations
 * <li>0 notifications
 * </ul>
 * 
 * @param result
 */
private static void addCompilationBeanInfo(HashMap<String, MBeanInfo> result) {
    // Attributes
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[3];
    attributes[0] = new MBeanAttributeInfo("Name", String.class.getName(),
            "Name", true, false, false);
    attributes[1] = new MBeanAttributeInfo("TotalCompilationTime",
            Long.TYPE.getName(), "TotalCompilationTime", true, false, false);
    attributes[2] = new MBeanAttributeInfo(
            "CompilationTimeMonitoringSupported", Boolean.TYPE.getName(),
            "CompilationTimeMonitoringSupported", true, false, true);
    result.put(CompilationMXBean.class.getName(), new MBeanInfo(
            CompilationMXBeanImpl.class.getName(),
            CompilationMXBeanImpl.class.getName(), attributes, null, null,
            null));
}
 
Example 11
Project: closure-compiler-old   File: JvmMetrics.java   View source code 6 votes vote down vote up
private static void writeJitMetrics(
    PrintStream out, boolean verbose, boolean pretty) {

  CompilationMXBean cBean = ManagementFactory.getCompilationMXBean();

  String name;
  if (verbose) {
    name = cBean.getName();
  } else {
    name = "total";
  }

  if (pretty) {
    out.println("\nJIT Stats");
    out.println(String.format(
        "\t%s jit time: %d ms", name, cBean.getTotalCompilationTime()));
  } else {
    out.println(normalizeTabularColonPos(String.format("%s-jit-time-ms : %d",
        normalizeName(name), cBean.getTotalCompilationTime())));
  }
}
 
Example 12
Project: closure-compiler-copy   File: JvmMetrics.java   View source code 6 votes vote down vote up
private static void writeJitMetrics(
    PrintStream out, boolean verbose, boolean pretty) {

  CompilationMXBean cBean = ManagementFactory.getCompilationMXBean();

  String name;
  if (verbose) {
    name = cBean.getName();
  } else {
    name = "total";
  }

  if (pretty) {
    out.println("\nJIT Stats");
    out.println(String.format(
        "\t%s jit time: %d ms", name, cBean.getTotalCompilationTime()));
  } else {
    out.println(normalizeTabularColonPos(String.format("%s-jit-time-ms : %d",
        normalizeName(name), cBean.getTotalCompilationTime())));
  }
}
 
Example 13
Project: jdk8u-jdk   File: MXBeanInteropTest1.java   View source code 5 votes vote down vote up
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 ;
}
 
Example 14
Project: openjdk-jdk10   File: MXBeanInteropTest1.java   View source code 5 votes vote down vote up
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 ;
}
 
Example 15
Project: openjdk9   File: MXBeanInteropTest1.java   View source code 5 votes vote down vote up
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 ;
}
 
Example 16
Project: jdk8u_jdk   File: MXBeanInteropTest1.java   View source code 5 votes vote down vote up
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 ;
}
 
Example 17
Project: lookaside_java-1.8.0-openjdk   File: MXBeanInteropTest1.java   View source code 5 votes vote down vote up
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 ;
}
 
Example 18
Project: jmxmon   File: ProxyClient.java   View source code 5 votes vote down vote up
public synchronized CompilationMXBean getCompilationMXBean() throws IOException {
    if (hasCompilationMXBean && compilationMBean == null) {
        compilationMBean =
            newPlatformMXBeanProxy(server, COMPILATION_MXBEAN_NAME,
                                   CompilationMXBean.class);
    }
    return compilationMBean;
}
 
Example 19
Project: systemml   File: Statistics.java   View source code 5 votes vote down vote up
/**
 * Returns the total time of asynchronous JIT compilation in milliseconds.
 * 
 * @return JIT compile time
 */
public static long getJITCompileTime(){
	long ret = -1; //unsupported
	CompilationMXBean cmx = ManagementFactory.getCompilationMXBean();
	if( cmx.isCompilationTimeMonitoringSupported() )
	{
		ret = cmx.getTotalCompilationTime();
		ret += jitCompileTime; //add from remote processes
	}
	return ret;
}
 
Example 20
Project: jvmtop   File: ProxyClient.java   View source code 5 votes vote down vote up
public synchronized CompilationMXBean getCompilationMXBean() throws IOException {
    if (hasCompilationMXBean && compilationMBean == null) {
        compilationMBean =
            newPlatformMXBeanProxy(server, COMPILATION_MXBEAN_NAME,
                                   CompilationMXBean.class);
    }
    return compilationMBean;
}
 
Example 21
Project: cn1   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testGetCompilationMXBean() {
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb);

    // Verify that there is only instance of this bean
    CompilationMXBean mb2 = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb2);
    assertSame(mb, mb2);
}
 
Example 22
Project: cn1   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testNewPlatformMXBeanProxy_CompilationMXBean() throws Exception {
    CompilationMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=Compilation", CompilationMXBean.class);
    assertNotNull(proxy);
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertEquals(mb.getName(), proxy.getName());
    assertEquals(mb.isCompilationTimeMonitoringSupported(), proxy
            .isCompilationTimeMonitoringSupported());
}
 
Example 23
Project: jmh   File: CompilerProfiler.java   View source code 5 votes vote down vote up
@Override
public boolean checkSupport(List<String> msgs) {
    CompilationMXBean comp = ManagementFactory.getCompilationMXBean();
    if (comp.isCompilationTimeMonitoringSupported()) {
        return true;
    } else {
        msgs.add("The MXBean is available, but compilation time monitoring is disabled.");
        return false;
    }
}
 
Example 24
Project: jmh   File: CompilerProfiler.java   View source code 5 votes vote down vote up
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
    CompilationMXBean comp = ManagementFactory.getCompilationMXBean();
    try {
        startCompTime = comp.getTotalCompilationTime();
    } catch (UnsupportedOperationException e) {
        startCompTime = -1;
    }
}
 
Example 25
Project: jmh   File: CompilerProfiler.java   View source code 5 votes vote down vote up
@Override
public Collection<? extends Result> afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
    long compTime = -startCompTime;
    CompilationMXBean comp = ManagementFactory.getCompilationMXBean();
    try {
        compTime += comp.getTotalCompilationTime();
    } catch (UnsupportedOperationException e) {
        compTime = -1;
    }

    return Arrays.asList(
            new ProfilerResult("@compiler.time.profiled", compTime, "ms", AggregationPolicy.SUM),
            new ProfilerResult("@compiler.time.total", comp.getTotalCompilationTime(), "ms", AggregationPolicy.MAX)
    );
}
 
Example 26
Project: commander-shell   File: JVM.java   View source code 5 votes vote down vote up
@Override
public void run() {
    CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
    if (compilationMXBean == null) {
        output.println("Couldn't get the runtime bean!");
        return;
    }
    output.println(compilationMXBean.getTotalCompilationTime());
}
 
Example 27
Project: freeVM   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testGetCompilationMXBean() {
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb);

    // Verify that there is only instance of this bean
    CompilationMXBean mb2 = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb2);
    assertSame(mb, mb2);
}
 
Example 28
Project: freeVM   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testNewPlatformMXBeanProxy_CompilationMXBean() throws Exception {
    CompilationMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=Compilation", CompilationMXBean.class);
    assertNotNull(proxy);
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertEquals(mb.getName(), proxy.getName());
    assertEquals(mb.isCompilationTimeMonitoringSupported(), proxy
            .isCompilationTimeMonitoringSupported());
}
 
Example 29
Project: freeVM   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testGetCompilationMXBean() {
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb);

    // Verify that there is only instance of this bean
    CompilationMXBean mb2 = ManagementFactory.getCompilationMXBean();
    assertNotNull(mb2);
    assertSame(mb, mb2);
}
 
Example 30
Project: freeVM   File: ManagementFactoryTest.java   View source code 5 votes vote down vote up
public void testNewPlatformMXBeanProxy_CompilationMXBean() throws Exception {
    CompilationMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
            ManagementFactory.getPlatformMBeanServer(),
            "java.lang:type=Compilation", CompilationMXBean.class);
    assertNotNull(proxy);
    CompilationMXBean mb = ManagementFactory.getCompilationMXBean();
    assertEquals(mb.getName(), proxy.getName());
    assertEquals(mb.isCompilationTimeMonitoringSupported(), proxy
            .isCompilationTimeMonitoringSupported());
}
 
Example 31
Project: incubator-netbeans   File: DiagnosticTask.java   View source code 4 votes vote down vote up
private String logParams() {
        StringBuilder sb = new StringBuilder(500);
        sb.append("Diagnostic information\n");
        try {
            RuntimeMXBean         rmBean     = ManagementFactory.getRuntimeMXBean();
            CompilationMXBean     cmpMBean   = ManagementFactory.getCompilationMXBean();
//            ThreadMXBean          tmBean     = ManagementFactory.getThreadMXBean();
            MemoryMXBean          memoryBean = ManagementFactory.getMemoryMXBean();
            ClassLoadingMXBean    clMBean    = ManagementFactory.getClassLoadingMXBean();

//            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
//            ObjectName hsDiag = new ObjectName("com.sun.management:name=HotSpotDiagnostic");
//            com.sun.management.OperatingSystemMXBean sunOSMBean  =
//               ManagementFactory.getSunOperatingSystemMXBean();

//            Map<String, String> props = new TreeMap<String, String>(rmBean.getSystemProperties());
//            System.out.println("System properties");
//            for (Map.Entry<String, String> entry: props.entrySet()) {
//                System.out.println("Property: "+entry.getKey()+" Value: "+entry.getValue());
//            }
            sb.append("Input arguments:");
            for (String s: rmBean.getInputArguments()) {
                sb.append("\n\t").append(s);
            }
            
            if (cmpMBean != null) {
                sb.append("\nCompiler: "+cmpMBean.getName()).append('\n');
            }
            
            // Memory
            MemoryUsage usage = memoryBean.getHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Heap memory");
            usage = memoryBean.getNonHeapMemoryUsage();
            logMemoryUsage(sb, usage, "Non heap memory");
            for (GarbageCollectorMXBean gcMBean: ManagementFactory.getGarbageCollectorMXBeans()) {
                sb.append("Garbage collector: ").append(gcMBean.getName())
                        .append(" (Collections=").append(gcMBean.getCollectionCount())
                        .append(" Total time spent=").append(formatTime(gcMBean.getCollectionTime()))
                        .append(")\n");
            }
            
            // classes
            int clsLoaded;
            long clsTotal, clsUnloaded;
            clsLoaded = clMBean.getLoadedClassCount();
            clsTotal = clMBean.getTotalLoadedClassCount();
            clsUnloaded = clMBean.getUnloadedClassCount();
            sb.append("Classes: loaded=").append(clsLoaded)
                    .append(" total loaded=").append(clsTotal)
                    .append(" unloaded ").append(clsUnloaded).append('\n');

//        } catch (MalformedObjectNameException ex) {
//            Logger.getLogger("global").log(Level.WARNING, null, ex);
        } catch (NullPointerException ex) {
            LOG.log(Level.WARNING, null, ex);
        }
        return sb.toString();
    }
 
Example 32
Project: OpenJSharp   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
Example 33
Project: jdk8u-jdk   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
Example 34
Project: java-performance   File: Compilation.java   View source code 4 votes vote down vote up
public static void main(String[] args) {
    CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
    System.out.println("Total compilation time: " + compilationMXBean.getTotalCompilationTime());
}
 
Example 35
Project: ServerAgent   File: CompilerDataProvider.java   View source code 4 votes vote down vote up
protected Class<CompilationMXBean> getMXBeanClass() {
	return CompilationMXBean.class;
}
 
Example 36
Project: ServerAgent   File: CompilerDataProvider.java   View source code 4 votes vote down vote up
protected long getValueFromBean(Object bean) {
	return ((CompilationMXBean) bean).getTotalCompilationTime();
}
 
Example 37
Project: jdk8u_jdk   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
Example 38
Project: lookaside_java-1.8.0-openjdk   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
Example 39
Project: infobip-open-jdk-8   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
Example 40
Project: jdk8u-dev-jdk   File: JvmCompilationImpl.java   View source code 4 votes vote down vote up
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}