Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Improve accuracy of time estimates
Browse files Browse the repository at this point in the history
This should be more accurate when the time to process one progress
unit is only a few milliseconds (or less than one millisecond).
  • Loading branch information
seanf committed Apr 11, 2014
1 parent c0d5409 commit e21d51f
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -60,11 +60,9 @@ public Optional<Long> getEstimatedTimeRemaining() {
if (this.startTime > 0 && currentProgress > 0) {
long currentTime = System.currentTimeMillis();
long timeElapsed = currentTime - this.startTime;
long averageTimePerProgressUnit =
timeElapsed / this.currentProgress;

return Optional.of(averageTimePerProgressUnit
* (this.maxProgress - this.currentProgress));
int remainingUnits = this.maxProgress - this.currentProgress;
return Optional.of(timeElapsed * remainingUnits
/ this.currentProgress);
} else {
return Optional.absent();
}
Expand Down

0 comments on commit e21d51f

Please sign in to comment.