diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-13 16:48:52 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-02-13 16:48:52 +0100 |
commit | edccc982e515e63a080a75fb49fd08b946f62cc6 (patch) | |
tree | 24b7d9984847a97ed1ce04ec042c2f44652ba2ce | |
parent | aa617ac09703f31e9f80836f8d8f9349b52578ee (diff) | |
download | busybox-w32-edccc982e515e63a080a75fb49fd08b946f62cc6.tar.gz busybox-w32-edccc982e515e63a080a75fb49fd08b946f62cc6.tar.bz2 busybox-w32-edccc982e515e63a080a75fb49fd08b946f62cc6.zip |
progress meter: add disabled code for a more stable ETA
Compiles to ~25 bytes if enabled.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/progress.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h index 2c34859a2..c02621d94 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1949,6 +1949,7 @@ typedef struct bb_progress_t { | |||
1949 | unsigned last_update_sec; | 1949 | unsigned last_update_sec; |
1950 | unsigned last_change_sec; | 1950 | unsigned last_change_sec; |
1951 | unsigned start_sec; | 1951 | unsigned start_sec; |
1952 | /*unsigned last_eta;*/ | ||
1952 | const char *curfile; | 1953 | const char *curfile; |
1953 | } bb_progress_t; | 1954 | } bb_progress_t; |
1954 | 1955 | ||
diff --git a/libbb/progress.c b/libbb/progress.c index f1d980d68..23e974ce7 100644 --- a/libbb/progress.c +++ b/libbb/progress.c | |||
@@ -57,6 +57,9 @@ void FAST_FUNC bb_progress_init(bb_progress_t *p, const char *curfile) | |||
57 | p->last_update_sec = p->start_sec; | 57 | p->last_update_sec = p->start_sec; |
58 | p->last_change_sec = p->start_sec; | 58 | p->last_change_sec = p->start_sec; |
59 | p->last_size = 0; | 59 | p->last_size = 0; |
60 | #if 0 | ||
61 | p->last_eta = INT_MAX; | ||
62 | #endif | ||
60 | } | 63 | } |
61 | 64 | ||
62 | /* File already had beg_size bytes. | 65 | /* File already had beg_size bytes. |
@@ -192,6 +195,16 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
192 | /* if 32bit, can overflow ^^^^^^^^^^, but this would only show bad ETA */ | 195 | /* if 32bit, can overflow ^^^^^^^^^^, but this would only show bad ETA */ |
193 | if (eta >= 1000*60*60) | 196 | if (eta >= 1000*60*60) |
194 | eta = 1000*60*60 - 1; | 197 | eta = 1000*60*60 - 1; |
198 | #if 0 | ||
199 | /* To prevent annoying "back-and-forth" estimation jitter, | ||
200 | * if new ETA is larger than the last just by a few seconds, | ||
201 | * disregard it, and show last one. The end result is that | ||
202 | * ETA usually only decreases, unless download slows down a lot. | ||
203 | */ | ||
204 | if ((unsigned)(eta - p->last_eta) < 10) | ||
205 | eta = p->last_eta; | ||
206 | p->last_eta = eta; | ||
207 | #endif | ||
195 | secs = eta % 3600; | 208 | secs = eta % 3600; |
196 | hours = eta / 3600; | 209 | hours = eta / 3600; |
197 | fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60); | 210 | fprintf(stderr, "%3u:%02u:%02u ETA", hours, secs / 60, secs % 60); |