+ const wgint ROW_BYTES = opt.dot_bytes * opt.dots_in_line;
+
+ /* bytes_displayed is the number of bytes indicated to the user by
+ dots printed so far, includes the initially "skipped" amount */
+ wgint bytes_displayed = dp->rows * ROW_BYTES + dp->dots * opt.dot_bytes;
+
+ if (last)
+ /* For last row also count bytes accumulated after last dot */
+ bytes_displayed += dp->accumulated;
+
+ if (dp->total_length)
+ {
+ /* Round to floor value to provide gauge how much data *has*
+ been retrieved. 12.8% will round to 12% because the 13% mark
+ has not yet been reached. 100% is only shown when done. */
+ int percentage = 100.0 * bytes_displayed / dp->total_length;
+ logprintf (LOG_VERBOSE, "%3d%%", percentage);
+ }
+
+ {
+ static char names[] = {' ', 'K', 'M', 'G'};
+ int units;
+ double rate;
+ wgint bytes_this_row;
+ if (!last)
+ bytes_this_row = ROW_BYTES;
+ else
+ /* For last row also include bytes accumulated after last dot. */
+ bytes_this_row = dp->dots * opt.dot_bytes + dp->accumulated;
+ /* Don't count the portion of the row belonging to initial_length */
+ if (dp->rows == dp->initial_length / ROW_BYTES)
+ bytes_this_row -= dp->initial_length % ROW_BYTES;
+ rate = calc_rate (bytes_this_row, dltime - dp->last_timer_value, &units);
+ logprintf (LOG_VERBOSE, " %4.*f%c",
+ rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2,
+ rate, names[units]);
+ dp->last_timer_value = dltime;
+ }
+
+ if (!last)
+ {
+ /* Display ETA based on average speed. Inspired by Vladi
+ Belperchinov-Shabanski's "wget-new-percentage" patch. */
+ if (dp->total_length)
+ {
+ wgint bytes_remaining = dp->total_length - bytes_displayed;
+ /* The quantity downloaded in this download run. */
+ wgint bytes_sofar = bytes_displayed - dp->initial_length;
+ double eta = dltime * bytes_remaining / bytes_sofar;
+ if (eta < INT_MAX - 1)
+ logprintf (LOG_VERBOSE, " %s",
+ eta_to_human_short ((int) (eta + 0.5), true));
+ }
+ }
+ else
+ {
+ /* When done, print the total download time */
+ if (dltime >= 10)
+ logprintf (LOG_VERBOSE, "=%s",
+ eta_to_human_short ((int) (dltime + 0.5), true));
+ else
+ logprintf (LOG_VERBOSE, "=%ss", print_decimal (dltime));
+ }