com.codahale.metrics.jvm.CpuTimeClock Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metrics-jvm Show documentation
Show all versions of metrics-jvm Show documentation
A set of classes which allow you to monitor critical aspects of your Java Virtual Machine
using Metrics.
The newest version!
package com.codahale.metrics.jvm;
import com.codahale.metrics.Clock;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
/**
* A clock implementation which returns the current thread's CPU time.
*/
public class CpuTimeClock extends Clock {
private static final ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean();
@Override
public long getTick() {
return THREAD_MX_BEAN.getCurrentThreadCpuTime();
}
}