当前位置: 首页>>代码示例>>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;未经允许,请勿转载。