Remove redundant System.nanoTime call
Avoids unnecessary redundant System.nanoTime calls in
PrioritizedSplitRunner#process() by storing the result of a single
call to ticker.read() in a local variable and reusing the value
for wall time and scheduled time durations.
@@ -161,18 +161,18 @@ public class PrioritizedSplitRunner
waitNanos.getAndAdd(startNanos - lastReady.get());
- long wallStart = System.nanoTime();
long cpuStart = THREAD_MX_BEAN.getCurrentThreadCpuTime();
ListenableFuture<?> blocked = split.processFor(SPLIT_RUN_QUANTA);
- long quantaCpuNanos = THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart;
- Duration wallDuration = new Duration(System.nanoTime() - wallStart, NANOSECONDS);
- long quantaScheduledNanos = ticker.read() - startNanos;
+ long quantaCpuNanos = THREAD_MX_BEAN.getCurrentThreadCpuTime() - cpuStart;
+ long endNanos = ticker.read();
+ long quantaScheduledNanos = endNanos - startNanos;
scheduledNanos.addAndGet(quantaScheduledNanos);
priority.set(taskHandle.addScheduledNanos(quantaScheduledNanos));
- lastRun.set(ticker.read());
+ lastRun.set(endNanos);
+ Duration wallDuration = new Duration(quantaScheduledNanos, NANOSECONDS);
if (blocked == NOT_BLOCKED) {
unblockedQuantaWallTime.add(wallDuration);
}
