From adrian@creative.net.au Wed Sep 15 06:26:41 1999
Return-Path: <adrian@creative.net.au>
Received: from ewok.creative.net.au (ewok.creative.net.au [203.30.44.41])
	by hub.freebsd.org (Postfix) with SMTP id 05C3D14E5C
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Sep 1999 06:26:35 -0700 (PDT)
	(envelope-from adrian@creative.net.au)
Received: (qmail 7795 invoked by uid 1001); 15 Sep 1999 13:26:34 -0000
Message-Id: <19990915132634.7794.qmail@ewok.creative.net.au>
Date: 15 Sep 1999 13:26:34 -0000
From: adrian@creative.net.au
Reply-To: adrian@ip.versatel.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: adding current download throughput output to fetch(1)
X-Send-Pr-Version: 3.2

>Number:         13758
>Category:       bin
>Synopsis:       [PATCH] adding current download throughput output to fetch(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 15 06:30:00 PDT 1999
>Closed-Date:    Fri Dec 1 03:10:03 PST 2000
>Last-Modified:  Fri Dec 01 03:11:03 PST 2000
>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:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: hoek 
Responsible-Changed-When: Tue May 16 10:08:16 PDT 2000 
Responsible-Changed-Why:  
You've got a replacement for fetch in the wings.  This is a pretty simple 
patch included in this PR.  Maybe not hard to apply to new fetch sources? 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Fri Dec 1 03:10:03 PST 2000 
State-Changed-Why:  
OBE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13758 
>Unformatted:
