https://github.com/javierbyte/time-remaning-estimator
Estimate the remaining time for any process with known progress.
https://github.com/javierbyte/time-remaning-estimator
Last synced: 5 months ago
JSON representation
Estimate the remaining time for any process with known progress.
- Host: GitHub
- URL: https://github.com/javierbyte/time-remaning-estimator
- Owner: javierbyte
- Created: 2017-01-10T05:37:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T05:56:45.000Z (over 9 years ago)
- Last Synced: 2025-06-20T22:42:31.479Z (about 1 year ago)
- Homepage:
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Time Remaining Estimator.
Estimate the time remaining for any process with known progress (Exponentially Weighted Moving Average implementation).
# Usage
### Automatic Timestamp.
```js
const estimator = new TimeRemainingEstimator.auto({
maxValue: 100
})
onProgress(function(newProgressValue) {
/* once you register progress, you can add it to the estimate
* to improve estimation
*/
estimator.add({
value: newProgressValue
})
estimator.calculate()
// {finalDate: , remainingTime: }
})
```
### Absolute Timestamp.
```js
const estimator = new TimeRemainingEstimator.absolute({
maxValue: 100,
startTime: processStartDate
})
onProgress(function(newProgressValue) {
/* here you can add points at any time in any order
* new points with the same time will override previous ones
*/
estimator.add({
value: newProgressValue,
time: new Date()
})
estimator.calculate({
time: new Date()
})
// {finalDate: , remainingTime: }
})
```
### Functional Usage.
```
TimeRemainingEstimator.functional({
maxValue: 100,
startTime: ,
currentTime: ,
steps: [{
time: ,
value: 1
}, {
time: ,
value: 3
}, {
time: ,
value: 23
}, {
time: ,
value: 55
}]
})
// returns {finalDate: , remainingTime: }
```
## How it works.
Implementation of https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average