@Test public void shouldFindSaneEpochTimestamp() { final OffsetEpochNanoClock clock = new OffsetEpochNanoClock(); final long startInMs = System.currentTimeMillis(); UnsafeAccess.UNSAFE.fullFence(); final long nanoTime = clock.nanoTime(); final long nanoTimeInMs = NANOSECONDS.toMillis(nanoTime); UnsafeAccess.UNSAFE.fullFence(); final long endInMs = System.currentTimeMillis(); assertThat(nanoTimeInMs, Matchers.lessThanOrEqualTo(endInMs)); assertThat(nanoTimeInMs, Matchers.greaterThanOrEqualTo(startInMs)); }
public long nanoTime() { final long nanoTimeAdjustment = System.nanoTime() - initialNanoTime; return initialCurrentTimeNanos + nanoTimeAdjustment; }
OffsetEpochNanoClock implements EpochNanoClock { public long nanoTime() { final long nanoTimeAdjustment = System.nanoTime() - initialNanoTime; return initialCurrentTimeNanos + nanoTimeAdjustment; } }
OffsetEpochNanoClock implements EpochNanoClock { public long nanoTime() { final long nanoTimeAdjustment = System.nanoTime() - initialNanoTime; return initialCurrentTimeNanos + nanoTimeAdjustment; } OffsetEpochNanoClock();  OffsetEpochNanoClock(final int maxMeasurementRetries, final long measurementThresholdInNs); }
OffsetEpochNanoClock implements EpochNanoClock { public long nanoTime() { final long nanoTimeAdjustment = System.nanoTime() - initialNanoTime; return initialCurrentTimeNanos + nanoTimeAdjustment; } OffsetEpochNanoClock();  OffsetEpochNanoClock(final int maxMeasurementRetries, final long measurementThresholdInNs); long nanoTime(); boolean isWithinThreshold(); }
OffsetEpochNanoClock implements EpochNanoClock { public long nanoTime() { final long nanoTimeAdjustment = System.nanoTime() - initialNanoTime; return initialCurrentTimeNanos + nanoTimeAdjustment; } OffsetEpochNanoClock();  OffsetEpochNanoClock(final int maxMeasurementRetries, final long measurementThresholdInNs); long nanoTime(); boolean isWithinThreshold();  }