X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fprogress.c;h=a0689f152ab3676ed8bfc1e5a7620df905512f09;hp=c79be386e69bf4d45023990c17c1692b817742e7;hb=d403f7f83522ffdd7d1e267fba378c1ea4fce273;hpb=45164e05ccd4a968db94165bbe0bd7df4b5fcd84 diff --git a/src/progress.c b/src/progress.c index c79be386..a0689f15 100644 --- a/src/progress.c +++ b/src/progress.c @@ -758,10 +758,12 @@ create_image (struct bar_progress *bp, double dl_total_time) { static char *short_units[] = { "B/s", "K/s", "M/s", "G/s" }; int units = 0; - long bytes = hist->total_bytes + bp->recent_bytes; - double tm = hist->total_time + dl_total_time - bp->recent_start; - double dlrate = calc_rate (bytes, tm, &units); - sprintf (p, " %7.2f%s", dlrate, short_units[units]); + /* Calculate the download speed using the history ring and + recent data that hasn't made it to the ring yet. */ + long dlquant = hist->total_bytes + bp->recent_bytes; + double dltime = hist->total_time + (dl_total_time - bp->recent_start); + double dlspeed = calc_rate (dlquant, dltime, &units); + sprintf (p, " %7.2f%s", dlspeed, short_units[units]); p += strlen (p); } else