All Downloads are FREE. Search and download functionalities are using the official Maven repository.

build.tmp.org.xbib.metrics.common.CpuTimeClock Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
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