Search in sources :

Example 1 with JvmCompilationMetrics

use of cn.myperf4j.base.metric.JvmCompilationMetrics in project MyPerf4J by ThinkpadNC5.

the class JvmCompilationCollector method collectCompilationMetrics.

public static JvmCompilationMetrics collectCompilationMetrics() {
    CompilationMXBean mxBean = COMPILATION_MX_BEAN;
    if (mxBean != null && mxBean.isCompilationTimeMonitoringSupported()) {
        long totalTime = mxBean.getTotalCompilationTime();
        long timeInterval = totalTime - lastTime;
        lastTime = totalTime;
        return new JvmCompilationMetrics(timeInterval, totalTime);
    }
    return new JvmCompilationMetrics(0L, 0L);
}
Also used : JvmCompilationMetrics(cn.myperf4j.base.metric.JvmCompilationMetrics) CompilationMXBean(java.lang.management.CompilationMXBean)

Example 2 with JvmCompilationMetrics

use of cn.myperf4j.base.metric.JvmCompilationMetrics in project MyPerf4J by ThinkpadNC5.

the class JvmMetricsScheduler method processCompilationMetrics.

private void processCompilationMetrics(long processId, long startMillis, long stopMillis) {
    compilationProcessor.beforeProcess(processId, startMillis, stopMillis);
    try {
        JvmCompilationMetrics metrics = JvmCompilationCollector.collectCompilationMetrics();
        compilationProcessor.process(metrics, processId, startMillis, stopMillis);
    } catch (Throwable t) {
        Logger.error("JvmMetricsScheduler.processCompilationMetrics(" + processId + ", " + startMillis + ", " + stopMillis + ")", t);
    } finally {
        compilationProcessor.afterProcess(processId, startMillis, stopMillis);
    }
}
Also used : JvmCompilationMetrics(cn.myperf4j.base.metric.JvmCompilationMetrics)

Example 3 with JvmCompilationMetrics

use of cn.myperf4j.base.metric.JvmCompilationMetrics in project MyPerf4J by ThinkpadNC5.

the class InfluxJvmCompilationMetricsFormatter method format.

@Override
public String format(List<JvmCompilationMetrics> metricsList, long startMillis, long stopMillis) {
    StringBuilder sb = SB_TL.get();
    try {
        long startNanos = startMillis * 1000 * 1000L;
        for (int i = 0; i < metricsList.size(); ++i) {
            JvmCompilationMetrics metrics = metricsList.get(i);
            appendLineProtocol(metrics, startNanos, sb);
            sb.append('\n');
        }
        return sb.substring(0, sb.length() - 1);
    } finally {
        sb.setLength(0);
    }
}
Also used : JvmCompilationMetrics(cn.myperf4j.base.metric.JvmCompilationMetrics)

Example 4 with JvmCompilationMetrics

use of cn.myperf4j.base.metric.JvmCompilationMetrics in project MyPerf4J by ThinkpadNC5.

the class StdJvmCompilationMetricsFormatter method format.

@Override
public String format(List<JvmCompilationMetrics> metricsList, long startMillis, long stopMillis) {
    String dataTitleFormat = "%-16s%16s%n";
    StringBuilder sb = new StringBuilder((metricsList.size() + 2) * (16 + 24));
    sb.append("MyPerf4J JVM Compilation Metrics [").append(DateFormatUtils.format(startMillis)).append(", ").append(DateFormatUtils.format(stopMillis)).append(']').append(LINE_SEPARATOR);
    sb.append(String.format(dataTitleFormat, "Time(ms)", "TotalTime(ms)"));
    if (metricsList.isEmpty()) {
        return sb.toString();
    }
    String dataFormat = "%-16d%16d%n";
    for (int i = 0; i < metricsList.size(); ++i) {
        JvmCompilationMetrics metrics = metricsList.get(i);
        sb.append(String.format(dataFormat, metrics.getTime(), metrics.getTotalTime()));
    }
    return sb.toString();
}
Also used : JvmCompilationMetrics(cn.myperf4j.base.metric.JvmCompilationMetrics)

Aggregations

JvmCompilationMetrics (cn.myperf4j.base.metric.JvmCompilationMetrics)4 CompilationMXBean (java.lang.management.CompilationMXBean)1