public CpuDuration startNewInterval() {
    long currentWallTime = System.nanoTime();
    long currentCpuTime = THREAD_MX_BEAN.getCurrentThreadCpuTime();
    long currentUserTime = THREAD_MX_BEAN.getCurrentThreadUserTime();

    CpuDuration cpuDuration =
        new CpuDuration(
            nanosBetween(intervalWallStart, currentWallTime),
            nanosBetween(intervalCpuStart, currentCpuTime),
            nanosBetween(intervalUserStart, currentUserTime));

    intervalWallStart = currentWallTime;
    intervalCpuStart = currentCpuTime;
    intervalUserStart = currentUserTime;

    return cpuDuration;
  }
this class is copied from
https://github.com/airlift/airlift/blob/214/stats/src/main/java/io/airlift/stats/CpuTimer.java as
it doesn't support Java8.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/stats/CpuTimer.java