Skip to content

Commit 4f77f61

Browse files
committed
Merge branch 'rs/progress-overall-throughput-at-the-end' into maint
The progress meter did not give a useful output when we haven't had 0.5 seconds to measure the throughput during the interval. Instead show the overall throughput rate at the end, which is a much more useful number. * rs/progress-overall-throughput-at-the-end: progress: show overall rate in last update
2 parents 49f1e2e + 0fae1e0 commit 4f77f61

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

progress.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct progress {
3636
unsigned delay;
3737
unsigned delayed_percent_treshold;
3838
struct throughput *throughput;
39+
uint64_t start_ns;
3940
};
4041

4142
static volatile sig_atomic_t progress_update;
@@ -221,6 +222,7 @@ struct progress *start_progress_delay(const char *title, unsigned total,
221222
progress->delayed_percent_treshold = percent_treshold;
222223
progress->delay = delay;
223224
progress->throughput = NULL;
225+
progress->start_ns = getnanotime();
224226
set_progress_signal();
225227
return progress;
226228
}
@@ -247,8 +249,10 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
247249
struct throughput *tp = progress->throughput;
248250

249251
if (tp) {
250-
unsigned int rate = !tp->avg_misecs ? 0 :
251-
tp->avg_bytes / tp->avg_misecs;
252+
uint64_t now_ns = getnanotime();
253+
unsigned int misecs, rate;
254+
misecs = ((now_ns - progress->start_ns) * 4398) >> 32;
255+
rate = tp->curr_total / (misecs ? misecs : 1);
252256
throughput_string(&tp->display, tp->curr_total, rate);
253257
}
254258
progress_update = 1;

0 commit comments

Comments
 (0)