[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Diety UI draft



Rob Browning <rlb@cs.utexas.edu> writes:

> How about always displaying a projected time to finish (a la ncftp)
> when downloading, and then store a weighted average of all the recent
> download rates to use in estimations.

I actually wrote a small script to just that a long time ago.  Here it
is for anyone that cares.  Very useful in lots of circumstances.  It
will give you an ETA if you give it the size.

#!/usr/bin/perl

$update = 1;
$keep = 60;

die "Usage: speed file [size]\n" if !@ARGV;
($file, $size) = @ARGV[0,1];
die "Can't stat $file\n" if ! -s $file;

print "Receiving $file";
print " ($size bytes)" if $size;
print ":\n";

$|=1;
$cnt=0;
for (;;) {
    $csize = -s $file;
    unshift(@hist, $csize);
    $now = ++$cnt>$keep ? $keep : $cnt;
    pop(@hist) if ($cnt>$keep);
    $speed = ($hist[0] - $hist[$now-1]) / $now;
    if ($size) {
	$per = $csize / $size * 100;
    }
    printf "%10ld bytes ", $csize;
    printf "(%2d%%)", $per if $size;
    printf " @ %4d bytes/sec", $speed;
    $eta=($size-$csize)/$speed if $size && $speed;
    printf "       ETA: %2d:%02d  ", int($eta / 60), $eta % 60 if $size;
    print "\r";
    sleep $update;
}


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: