Skip to content

Commit

Permalink
Fix divide by zero error in ZestGuidance.displayStats (#218)
Browse files Browse the repository at this point in the history
Ensures that the interval is at least 1 millisecond.
  • Loading branch information
claudeyj committed Apr 26, 2023
1 parent 146ae4d commit abdc7e8
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ protected String millisToDuration(long millis) {
protected void displayStats(boolean force) {
Date now = new Date();
long intervalMilliseconds = now.getTime() - lastRefreshTime.getTime();
intervalMilliseconds = Math.max(1, intervalMilliseconds);
if (intervalMilliseconds < STATS_REFRESH_TIME_PERIOD && !force) {
return;
}
Expand All @@ -478,6 +479,7 @@ protected void displayStats(boolean force) {
lastRefreshTime = now;
lastNumTrials = numTrials;
long elapsedMilliseconds = now.getTime() - startTime.getTime();
elapsedMilliseconds = Math.max(1, elapsedMilliseconds);
long execsPerSec = numTrials * 1000L / elapsedMilliseconds;

String currentParentInputDesc;
Expand Down

0 comments on commit abdc7e8

Please sign in to comment.