Skip site navigation (1)Skip section navigation (2)
Date:      15 Sep 1999 13:26:34 -0000
From:      adrian@creative.net.au
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/13758: adding current download throughput output to fetch(1)
Message-ID:  <19990915132634.7794.qmail@ewok.creative.net.au>

next in thread | raw e-mail | index | archive | help

>Number:         13758
>Category:       bin
>Synopsis:       adding current download throughput output to fetch(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 15 06:30:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Adrian Chadd
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

FreeBSD ywing.m2.ip.versatel.net 4.0-CURRENT FreeBSD 4.0-CURRENT #0:
Tue Sep 14 19:33:30 CEST 1999

>Description:

I thought it might be useful to have fetch(1) return a 'current throughput'
indicator so I could see how fast the download is.

The patch below does this, over the last 5 second interval. I thought that
having it over the whole transfer period was kind of pointless, because :

(a) I like to see when things start to bottleneck, and not have it hidden
    by a fast download, and
(b) You get it at the end anyway. :-)

>How-To-Repeat:

Just run fetch..

>Fix:
	
Here's the quick patch to fetch(1) in -current:

Index: fetch/main.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/fetch/main.c,v
retrieving revision 1.53
diff -u -r1.53 main.c
--- main.c      1999/08/28 01:00:51     1.53
+++ main.c      1999/09/15 12:40:42
@@ -319,9 +319,11 @@
     static int pr, stdoutatty, init = 0;
     static struct timeval t0, t_start;
     static char *s;
+    static u_quad_t lastbc = 0;
     struct timezone tz;
     struct timeval t;
     float d;
+    float speed;
     
     if (!fs->fs_verbose)
        return;
@@ -377,6 +379,12 @@
            fprintf (stderr, "\r%s: %2qd%%", s, (long long)(100*bytes/size));
        else
            fprintf (stderr, "\r%s: %qd Kbytes", s, (long long)(bytes/1024));
+       speed = ((float)bytes - (float)lastbc) / 5.0;
+       lastbc = bytes;
+       if (speed > 1000.0)
+               fprintf(stderr, " (%.2f Kbytes/s)", speed / 1000.0);
+       else
+               fprintf(stderr, " (%.0f bytes/s)", speed);
     }
 }



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990915132634.7794.qmail>