In CPUTimeMetricQueryRunner, account CPU consumed in baseSequence.toYielder() (#3587)

This commit is contained in:
Roman Leventov 2016-10-18 17:06:42 +03:00 committed by Gian Merlino
parent 2c5c8198db
commit b113a34355
1 changed files with 11 additions and 10 deletions

View File

@ -85,11 +85,16 @@ public class CPUTimeMetricQueryRunner<T> implements QueryRunner<T>
}
@Override
public <OutType> Yielder<OutType> toYielder(
OutType initValue, YieldingAccumulator<OutType, T> accumulator
)
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator)
{
final Yielder<OutType> delegateYielder = baseSequence.toYielder(initValue, accumulator);
final long start = VMUtils.getCurrentThreadCpuTime();
final Yielder<OutType> delegateYielder;
try {
delegateYielder = baseSequence.toYielder(initValue, accumulator);
}
finally {
cpuTimeAccumulator.addAndGet(VMUtils.getCurrentThreadCpuTime() - start);
}
return new Yielder<OutType>()
{
@Override
@ -100,9 +105,7 @@ public class CPUTimeMetricQueryRunner<T> implements QueryRunner<T>
return delegateYielder.get();
}
finally {
cpuTimeAccumulator.addAndGet(
VMUtils.getCurrentThreadCpuTime() - start
);
cpuTimeAccumulator.addAndGet(VMUtils.getCurrentThreadCpuTime() - start);
}
}
@ -114,9 +117,7 @@ public class CPUTimeMetricQueryRunner<T> implements QueryRunner<T>
return delegateYielder.next(initValue);
}
finally {
cpuTimeAccumulator.addAndGet(
VMUtils.getCurrentThreadCpuTime() - start
);
cpuTimeAccumulator.addAndGet(VMUtils.getCurrentThreadCpuTime() - start);
}
}