Java Code Examples for java.lang.management.CompilationMXBean#isCompilationTimeMonitoringSupported()
The following examples show how to use
java.lang.management.CompilationMXBean#isCompilationTimeMonitoringSupported() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompilationTimeSensor.java From swage with Apache License 2.0 | 6 votes |
@Override public void sense(final MetricContext 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
Source File: MXBeanInteropTest1.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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 3
Source File: MXBeanInteropTest1.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 4
Source File: Statistics.java From systemds with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: MXBeanInteropTest1.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 6
Source File: JvmCompilationMetrics.java From micrometer with Apache License 2.0 | 5 votes |
@Override public void bindTo(MeterRegistry registry) { CompilationMXBean compilationBean = ManagementFactory.getCompilationMXBean(); if (compilationBean != null && compilationBean.isCompilationTimeMonitoringSupported()) { FunctionCounter.builder("jvm.compilation.time", compilationBean, CompilationMXBean::getTotalCompilationTime) .tags(Tags.concat(tags, "compiler", compilationBean.getName())) .description("The approximate accumulated elapsed time spent in compilation") .baseUnit(BaseUnits.MILLISECONDS) .register(registry); } }
Example 7
Source File: Test.java From ClusterDeviceControlPlatform with MIT License | 5 votes |
private static void printCompilationInfo() { CompilationMXBean compilation = ManagementFactory.getCompilationMXBean(); System.out.println("JIT编译器名称:" + compilation.getName()); //判断jvm是否支持编译时间的监控 if (compilation.isCompilationTimeMonitoringSupported()) { System.out.println("总编译时间:" + compilation.getTotalCompilationTime() + "秒"); } }
Example 8
Source File: Test.java From ClusterDeviceControlPlatform with MIT License | 5 votes |
private static void printCompilationInfo() { CompilationMXBean compilation = ManagementFactory.getCompilationMXBean(); System.out.println("JIT编译器名称:" + compilation.getName()); //判断jvm是否支持编译时间的监控 if (compilation.isCompilationTimeMonitoringSupported()) { System.out.println("总编译时间:" + compilation.getTotalCompilationTime() + "秒"); } }
Example 9
Source File: MXBeanInteropTest1.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 10
Source File: MXBeanInteropTest1.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 11
Source File: MXBeanInteropTest1.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 12
Source File: MXBeanInteropTest1.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 13
Source File: Statistics.java From systemds with Apache License 2.0 | 5 votes |
/** * 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 14
Source File: ClassData.java From openjdk-systemtest with Apache License 2.0 | 4 votes |
/** * This method writes the data retrieved from the ClassLoading and * Compilation MXBeans to the ClassData's log using the MXBeans directly or * through a proxy. * * @param clb * The ClassLoading MXBean used to retrieve information about * loaded classes. * @param cb * The Compilation MXBean used to retrieve compilation * information. * @param rb * The Runtime MXBean used to retrieve general information about * the runtime used. * @param append * If the append value is true the data is appended to the log, * otherwise the log is overwritten. */ public void writeData(ClassLoadingMXBean clb, CompilationMXBean cb, RuntimeMXBean rb, boolean append) throws UndeclaredThrowableException { if ((clb == null)) { Assert.fail("ClassLoadingMXBean is null"); } openLogFile(append); DecimalFormat df = new DecimalFormat("#0.00"); // Print out all times to 2 d.p. try { // Record the time and whether the verbose output is enabled out.println("Class Loading and Compilation Information Retrieved at " + DateFormat.getDateTimeInstance().format(new Date())); out.println(""); // Get stats for the class loader, check the values and write them to a file int load_cls_cnt = clb.getLoadedClassCount(); long unload_cls_cnt = clb.getUnloadedClassCount(); long total_cls_cnt = clb.getTotalLoadedClassCount(); // Check the class counts are valid checkClassCounts("proxy", load_cls_cnt, unload_cls_cnt, total_cls_cnt); // Print the results to the log out.println("CLASS LOADING STATS"); out.println(" Current Loaded Class Count: " + load_cls_cnt); out.println(" Total Unloaded Class Count: " + unload_cls_cnt); out.println(" Total Loaded Class Count: " + total_cls_cnt); out.print(" Verbose output enabled: "); if (clb.isVerbose()) { out.println("Yes"); } else { out.println("No"); } out.println(""); out.println(""); // If there is a compiler get the info Map<String, String> props = rb.getSystemProperties(); String sys_comp = props.get("java.compiler"); if ((sys_comp != null) && (!(sys_comp.equals("")))) { // Get the info for the compiler and write to file out.println("COMPILER INFORMATION"); String mxbean_comp = cb.getName(); // Check if the compiler matches the compiler specified in the system properties checkCompiler("proxy", sys_comp, mxbean_comp); out.println(" Just-in-time (JIT) compiler: " + mxbean_comp); if (cb.isCompilationTimeMonitoringSupported()) { out.println(" Total Compilation Time: " + df.format(cb.getTotalCompilationTime() * 1e-3) + " seconds"); // Convert milliseconds to seconds } out.println(""); out.println(""); } closeLogFile(); } catch (UnsupportedOperationException uoe) { Message.logOut("One of the operations you tried is not supported"); uoe.printStackTrace(); Assert.fail("One of the operations you tried is not supported"); } }