Prevent div by 0
@@ -28,10 +28,13 @@ public class AverageTimeComponent extends TimeComponent {
if (currentStepNow != 0) {
averageStepTime = Duration.between(elapsedTime.getStartTime(), Instant.now()).dividedBy(currentStepNow);
+ long averageStepTimeNanos = averageStepTime.toNanos();
+ if(averageStepTimeNanos != 0) {
long stepsSecond = NANOS_IN_SECOND / averageStepTime.toNanos();
renderedString.append(", Steps per second: ");
renderedString.append(stepsSecond);
}
+ }
return renderedString.toString();
}
