This is a small patch to progressmeter.c that provides peak throughput
information. It adds a new field on the progress bar line that displays
the 1sec throughput for the connection. At the end of the transfer it
spits out the peak throughput seen.

I found it useful in some testing situations and maybe someone else
might find it handy.

--- ../openssh-4.7p1.logging_features/progressmeter.c 2006-08-04
22:39:40.000000000 -0400
+++ progressmeter.c 2007-10-22 13:19:11.000000000 -0400
@@ -68,7 +68,9 @@ static time_t last_update; /* last progr
static char *file; /* name of the file being transferred */
static off_t end_pos; /* ending position of transfer */
static off_t cur_pos; /* transfer position as of last refresh */
-static volatile off_t *counter; /* progress counter */
+static off_t last_pos;
+static off_t max_delta_pos = 0;
+static volatile off_t *counter; /* progress counter */
static long stalled; /* how long we have been stalled */
static int bytes_per_second; /* current speed in bytes per second */
static int win_size; /* terminal window size */
@@ -128,11 +130,16 @@ refresh_progress_meter(void)
int hours, minutes, seconds;
int i, len;
int file_len;
+ off_t delta_pos;

transferred = *counter - cur_pos;
cur_pos = *counter;
now = time(NULL);
bytes_left = end_pos - cur_pos;
+
+ delta_pos = cur_pos - last_pos;
+ if (delta_pos > max_delta_pos)
+ max_delta_pos = delta_pos;

if (bytes_left > 0)
elapsed = now - last_update;
@@ -158,7 +165,7 @@ refresh_progress_meter(void)

/* filename */
buf[0] = '\0';
- file_len = win_size - 35;
+ file_len = win_size - 45;
if (file_len > 0) {
len = snprintf(buf, file_len + 1, "\r%s", file);
if (len < 0)
@@ -175,7 +182,8 @@ refresh_progress_meter(void)
percent = ((float)cur_pos / end_pos) * 100;
else
percent = 100;
- snprintf(buf + strlen(buf), win_size - strlen(buf),
+
+ snprintf(buf + strlen(buf), win_size - strlen(buf-8),
" %3d%% ", percent);

/* amount transferred */
@@ -188,6 +196,11 @@ refresh_progress_meter(void)
(off_t)bytes_per_second);
strlcat(buf, "/s ", win_size);

+ /* instantaneous rate */
+ format_rate(buf + strlen(buf), win_size - strlen(buf),
+ delta_pos);
+ strlcat(buf, "/s ", win_size);
+
/* ETA */
if (!transferred)
stalled += elapsed;
@@ -224,6 +237,7 @@ refresh_progress_meter(void)

atomicio(vwrite, STDOUT_FILENO, buf, win_size - 1);
last_update = now;
+ last_pos = cur_pos;
}

/*ARGSUSED*/
@@ -270,6 +284,7 @@ void
stop_progress_meter(void)
{
alarm(0);
+ char lbuf[10];

if (!can_output())
return;
@@ -277,7 +292,9 @@ stop_progress_meter(void)
/* Ensure we complete the progress */
if (cur_pos != end_pos)
refresh_progress_meter();
-
+
+ format_rate(lbuf, sizeof(lbuf), max_delta_pos);
+ printf("\nMax throughput: %s/s\n", lbuf);
atomicio(vwrite, STDOUT_FILENO, "\n", 1);
}
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/li...enssh-unix-dev