org.xbib.metrics.common.CpuTimeClock Maven / Gradle / Ivy
package org.xbib.metrics.common;
import org.xbib.metrics.api.Clock;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
/**
* A clock implementation which returns the current thread's CPU time.
*/
class CpuTimeClock implements Clock {
private static final ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean();
@Override
public long getTick() {
return THREAD_MX_BEAN.getCurrentThreadCpuTime();
}
@Override
public long getTime() {
return System.currentTimeMillis();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy