Avoid accessing atomic twice
@@ -17,8 +17,9 @@ public class AverageTimeComponent extends TimeComponent {
@Override
public String render() {
String result = elapsedTime.render();
- if (currentStep.get() != 0) {
- averageStepTime = Duration.between(elapsedTime.getStartTime(), Instant.now()).dividedBy(currentStep.get());
+ long currentStepNow = currentStep.get();
+ if (currentStepNow != 0) {
+ averageStepTime = Duration.between(elapsedTime.getStartTime(), Instant.now()).dividedBy(currentStepNow);
result += ", Average step time: " + formatDuration(averageStepTime);
}
return result;
