Package com.pervasivecode.utils.stats
Interface DurationEstimator
-
- All Known Implementing Classes:
SimpleDurationEstimator
public interface DurationEstimator
This object can estimate the rate at which a repeatedly set progress value is currently changing, and can estimate how long it will take for that value to reach a specified target value.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description float
estimatedRateAsAmountPerSecond()
Return an estimate of the current rate of progress, in terms of user-defined progress units per second.Optional<Duration>
estimateTimeToProcessAmount(long amountLeft)
Return an estimate of the amount of time that must elapse starting from the current time, in order for the specified amount to be processed.void
recordAmountSoFar(long amountSoFar)
Set the progress counter to the specified value.
-
-
-
Method Detail
-
recordAmountSoFar
void recordAmountSoFar(long amountSoFar)
Set the progress counter to the specified value.- Parameters:
amountSoFar
- The current total amount of progress in whatever units the caller wants to track.
-
estimatedRateAsAmountPerSecond
float estimatedRateAsAmountPerSecond()
Return an estimate of the current rate of progress, in terms of user-defined progress units per second.- Returns:
- The estimate, in units of amount per second.
-
estimateTimeToProcessAmount
Optional<Duration> estimateTimeToProcessAmount(long amountLeft)
Return an estimate of the amount of time that must elapse starting from the current time, in order for the specified amount to be processed.Example: if estimatedRateAsAmountPerSecond() would return 4.0f, and the amountLeft provided is 44, this method will return a Duration of 11 seconds.
- Parameters:
amountLeft
- The amount that remains to be processed, and about which the caller wants a duration estimate.- Returns:
- The estimated duration. If it is impossible to compute an estimate (such as because the rate is 0), Optional.empty is returned.
-
-