List of usage examples for com.google.common.math LongMath mean
public static long mean(long x, long y)
From source file:com.teradata.benchto.driver.listeners.BenchmarkServiceExecutionListener.java
private void checkClocksSync() { long timeBefore = System.currentTimeMillis(); long serviceTime = benchmarkServiceClient.getServiceCurrentTime().toEpochMilli(); long timeAfter = System.currentTimeMillis(); long driftApproximation = Math.abs(LongMath.mean(timeBefore, timeAfter) - serviceTime); long approximationPrecision = timeAfter - LongMath.mean(timeBefore, timeAfter); Duration driftLowerBound = Duration.of(driftApproximation - approximationPrecision, ChronoUnit.MILLIS); if (driftLowerBound.compareTo(MAX_CLOCK_DRIFT) > 1) { throw new RuntimeException( format("Detected driver and service clocks drift of at least %s, assumed sane maximum is %s", driftLowerBound, MAX_CLOCK_DRIFT)); }//from www . j a v a 2 s . c o m }