當前位置: 首頁>>代碼示例>>Java>>正文


Java ManagementFactory.getCompilationMXBean方法代碼示例

本文整理匯總了Java中java.lang.management.ManagementFactory.getCompilationMXBean方法的典型用法代碼示例。如果您正苦於以下問題:Java ManagementFactory.getCompilationMXBean方法的具體用法?Java ManagementFactory.getCompilationMXBean怎麽用?Java ManagementFactory.getCompilationMXBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.management.ManagementFactory的用法示例。


在下文中一共展示了ManagementFactory.getCompilationMXBean方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sense

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
@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;
}
 
開發者ID:awslabs,項目名稱:swage,代碼行數:17,代碼來源:CompilationTimeSensor.java

示例2: logParams

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
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();
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:59,代碼來源:DiagnosticTask.java

示例3: getCompilationMXBean

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
private static CompilationMXBean getCompilationMXBean() {
    return ManagementFactory.getCompilationMXBean();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:4,代碼來源:JvmCompilationImpl.java

示例4: main

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
/**
 * Entry point. Compiles classes in {@code paths}
 *
 * @param paths paths to jar/zip, dir contains classes, or to .lst file
 *              contains list of classes to compile
 */
public static void main(String[] paths) {
    if (paths.length == 0) {
        throw new IllegalArgumentException("Expect a path to a compile target.");
    }
    String logfile = Utils.LOG_FILE;
    PrintStream os = null;
    if (logfile != null) {
        try {
            os = new PrintStream(Files.newOutputStream(Paths.get(logfile)));
        } catch (IOException io) {
        }
    }
    if (os != null) {
        OUT = os;
    }

    boolean passed = false;

    try {
        try {
            if (ManagementFactory.getCompilationMXBean() == null) {
                throw new RuntimeException(
                        "CTW can not work in interpreted mode");
            }
        } catch (java.lang.NoClassDefFoundError e) {
            // compact1, compact2 support
        }
        ExecutorService executor = createExecutor();
        long start = System.currentTimeMillis();
        try {
            Arrays.stream(paths)
                  .map(PathHandler::create)
                  .flatMap(List::stream)
                  .forEach(p -> {
                      try {
                          p.process(executor);
                      } finally {
                          p.close();
                      }
                    });
        } finally {
            await(executor);
        }
        CompileTheWorld.OUT.printf("Done (%d classes, %d methods, %d ms)%n",
                PathHandler.getProcessedClassCount(),
                Compiler.getMethodCount(),
                System.currentTimeMillis() - start);
        passed = true;
    } catch (Throwable t){
        t.printStackTrace(ERR);
    } finally {
        try {
            OUT.close();
        } catch (Throwable ignore) {
        }
        // <clinit> might have started new threads
        System.exit(passed ? 0 : 1);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:66,代碼來源:CompileTheWorld.java

示例5: main

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
    CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
    System.out.println("Total compilation time: " + compilationMXBean.getTotalCompilationTime());
}
 
開發者ID:kslisenko,項目名稱:java-performance,代碼行數:5,代碼來源:Compilation.java

示例6: createJvmCompilationMetaNode

import java.lang.management.ManagementFactory; //導入方法依賴的package包/類
/**
 * Factory method for "JvmCompilation" group metadata class.
 *
 * You can redefine this method if you need to replace the default
 * generated metadata class with your own customized class.
 *
 * @param groupName Name of the group ("JvmCompilation")
 * @param groupOid  OID of this group
 * @param groupObjname ObjectName for this group (may be null)
 * @param server    MBeanServer for this group (may be null)
 *
 * @return An instance of the metadata class generated for the
 *         "JvmCompilation" group (JvmCompilationMeta)
 *
 **/
protected JvmCompilationMeta
    createJvmCompilationMetaNode(String groupName,
                                 String groupOid,
                                 ObjectName groupObjname,
                                 MBeanServer server)  {
    // If there is no compilation system, the jvmCompilation  will not
    // be instantiated.
    //
    if (ManagementFactory.getCompilationMXBean() == null) return null;
    return super.createJvmCompilationMetaNode(groupName,groupOid,
                                              groupObjname,server);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:JVM_MANAGEMENT_MIB_IMPL.java


注:本文中的java.lang.management.ManagementFactory.getCompilationMXBean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。