本文整理匯總了Java中java.lang.management.CompilationMXBean類的典型用法代碼示例。如果您正苦於以下問題:Java CompilationMXBean類的具體用法?Java CompilationMXBean怎麽用?Java CompilationMXBean使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CompilationMXBean類屬於java.lang.management包,在下文中一共展示了CompilationMXBean類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sense
import java.lang.management.CompilationMXBean; //導入依賴的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;
}
示例2: main
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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");
}
}
示例3: main
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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");
}
}
示例4: writeJitMetrics
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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())));
}
}
示例5: writeJitMetrics
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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())));
}
}
示例6: addCompilationBeanInfo
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
/**
* 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));
}
示例7: doCompilationMXBeanTest
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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 ;
}
示例8: getCompilationMXBean
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
public synchronized CompilationMXBean getCompilationMXBean() throws IOException {
if (hasCompilationMXBean && compilationMBean == null) {
compilationMBean =
newPlatformMXBeanProxy(server, COMPILATION_MXBEAN_NAME,
CompilationMXBean.class);
}
return compilationMBean;
}
示例9: getJITCompileTime
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
/**
* 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;
}
示例10: testGetCompilationMXBean
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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);
}
示例11: testNewPlatformMXBeanProxy_CompilationMXBean
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
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());
}
示例12: checkSupport
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
@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;
}
}
示例13: beforeIteration
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
@Override
public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) {
CompilationMXBean comp = ManagementFactory.getCompilationMXBean();
try {
startCompTime = comp.getTotalCompilationTime();
} catch (UnsupportedOperationException e) {
startCompTime = -1;
}
}
示例14: afterIteration
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
@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)
);
}
示例15: run
import java.lang.management.CompilationMXBean; //導入依賴的package包/類
@Override
public void run() {
CompilationMXBean compilationMXBean = ManagementFactory.getCompilationMXBean();
if (compilationMXBean == null) {
output.println("Couldn't get the runtime bean!");
return;
}
output.println(compilationMXBean.getTotalCompilationTime());
}