mirror of
https://github.com/mirror/wget.git
synced 2025-02-01 15:20:08 +08:00
[svn] Display smaller download rate numbers with more digits of precision.
This commit is contained in:
parent
f238f09492
commit
176b61461b
@ -1,3 +1,10 @@
|
|||||||
|
2005-07-02 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* progress.c (create_image): Ditto.
|
||||||
|
|
||||||
|
* retr.c (retr_rate): Display smaller rate numbers with greater
|
||||||
|
precision.
|
||||||
|
|
||||||
2005-07-02 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-07-02 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* http.c (response_head_terminator): Minor optimization.
|
* http.c (response_head_terminator): Minor optimization.
|
||||||
|
@ -306,7 +306,7 @@ print_row_stats (struct dot_progress *dp, double dltime, bool last)
|
|||||||
bytes_this_row -= 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);
|
rate = calc_rate (bytes_this_row, dltime - dp->last_timer_value, &units);
|
||||||
logprintf (LOG_VERBOSE, " %4.*f%c",
|
logprintf (LOG_VERBOSE, " %4.*f%c",
|
||||||
rate >= 100 ? 0 : rate >= 9.995 ? 1 : 2,
|
rate >= 99.95 ? 0 : rate >= 9.995 ? 1 : 2,
|
||||||
rate, names[units]);
|
rate, names[units]);
|
||||||
dp->last_timer_value = dltime;
|
dp->last_timer_value = dltime;
|
||||||
}
|
}
|
||||||
@ -787,13 +787,13 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
|
|||||||
"xx% " or "100%" - percentage - 4 chars
|
"xx% " or "100%" - percentage - 4 chars
|
||||||
"[]" - progress bar decorations - 2 chars
|
"[]" - progress bar decorations - 2 chars
|
||||||
" nnn,nnn,nnn" - downloaded bytes - 12 chars or very rarely more
|
" nnn,nnn,nnn" - downloaded bytes - 12 chars or very rarely more
|
||||||
" 1012.56K/s" - dl rate - 11 chars
|
" 12.5K/s" - download rate - 8 chars
|
||||||
" eta 36m 51s" - ETA - 13 chars
|
" eta 36m 51s" - ETA - 13 chars
|
||||||
|
|
||||||
"=====>..." - progress bar - the rest
|
"=====>..." - progress bar - the rest
|
||||||
*/
|
*/
|
||||||
int dlbytes_size = 1 + MAX (size_grouped_len, 11);
|
int dlbytes_size = 1 + MAX (size_grouped_len, 11);
|
||||||
int progress_size = bp->width - (4 + 2 + dlbytes_size + 11 + 13);
|
int progress_size = bp->width - (4 + 2 + dlbytes_size + 8 + 13);
|
||||||
|
|
||||||
if (progress_size < 5)
|
if (progress_size < 5)
|
||||||
progress_size = 0;
|
progress_size = 0;
|
||||||
@ -878,7 +878,7 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
|
|||||||
sprintf (p, " %-11s", size_grouped);
|
sprintf (p, " %-11s", size_grouped);
|
||||||
move_to_end (p);
|
move_to_end (p);
|
||||||
|
|
||||||
/* " 1012.45K/s" */
|
/* " 12.52K/s" */
|
||||||
if (hist->total_time && hist->total_bytes)
|
if (hist->total_time && hist->total_bytes)
|
||||||
{
|
{
|
||||||
static const char *short_units[] = { "B/s", "K/s", "M/s", "G/s" };
|
static const char *short_units[] = { "B/s", "K/s", "M/s", "G/s" };
|
||||||
@ -888,11 +888,12 @@ create_image (struct bar_progress *bp, double dl_total_time, bool done)
|
|||||||
wgint dlquant = hist->total_bytes + bp->recent_bytes;
|
wgint dlquant = hist->total_bytes + bp->recent_bytes;
|
||||||
double dltime = hist->total_time + (dl_total_time - bp->recent_start);
|
double dltime = hist->total_time + (dl_total_time - bp->recent_start);
|
||||||
double dlspeed = calc_rate (dlquant, dltime, &units);
|
double dlspeed = calc_rate (dlquant, dltime, &units);
|
||||||
sprintf (p, " %7.2f%s", dlspeed, short_units[units]);
|
sprintf (p, " %4.*f%s", dlspeed >= 99.95 ? 0 : dlspeed >= 9.995 ? 1 : 2,
|
||||||
|
dlspeed, short_units[units]);
|
||||||
move_to_end (p);
|
move_to_end (p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
APPEND_LITERAL (" --.--K/s");
|
APPEND_LITERAL (" --.-K/s");
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
{
|
{
|
||||||
|
@ -521,10 +521,14 @@ retr_rate (wgint bytes, double msecs)
|
|||||||
{
|
{
|
||||||
static char res[20];
|
static char res[20];
|
||||||
static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" };
|
static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" };
|
||||||
int units = 0;
|
int units;
|
||||||
|
|
||||||
double dlrate = calc_rate (bytes, msecs, &units);
|
double dlrate = calc_rate (bytes, msecs, &units);
|
||||||
sprintf (res, "%.2f %s", dlrate, rate_names[units]);
|
/* Use more digits for smaller numbers (regardless of unit used),
|
||||||
|
e.g. "1022", "247", "12.5", "2.38". */
|
||||||
|
sprintf (res, "%.*f %s",
|
||||||
|
dlrate >= 99.95 ? 0 : dlrate >= 9.995 ? 1 : 2,
|
||||||
|
dlrate, rate_names[units]);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user