From 29687a8502e38b16a59c7a06b56c56bc7967faf0 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 16 Jun 2002 21:15:26 +0000 Subject: [PATCH] Fixed filetransfer speed calculation --- ChangeLog | 2 ++ mbcico/filelist.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ce68c96..cf49ba0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,8 @@ v0.35.01 05-Jun-2002 Irex and patched BinkP versions. Better error handling for error conditions during a binkp session. + Fixed a problem with the calculated filetransfer speed with + large files on fast connections. mbfile: Added -v commandline switch to supress virus checking for the diff --git a/mbcico/filelist.c b/mbcico/filelist.c index e67864c2..3710fbca 100644 --- a/mbcico/filelist.c +++ b/mbcico/filelist.c @@ -477,16 +477,20 @@ void execute_disposition(file_list *fl) char *transfertime(struct timeval start, struct timeval end, long bytes, int sent) { - static char resp[81]; - long startms, endms, elapsed; + static char resp[81]; + double long startms, endms, elapsed; - memset(&resp, 0, sizeof(resp)); startms = (start.tv_sec * 1000) + (start.tv_usec / 1000); endms = (end.tv_sec * 1000) + (end.tv_usec / 1000); elapsed = endms - startms; + memset(&resp, 0, sizeof(resp)); if (!elapsed) elapsed = 1L; - sprintf(resp, "%ld bytes %s in %0.3f seconds (%ld cps)", + if (bytes > 1000000) + sprintf(resp, "%ld bytes %s in %0.3Lf seconds (%0.0Lf cps)", + bytes, sent?"sent":"received", elapsed / 1000.000, (bytes / elapsed) * 1000); + else + sprintf(resp, "%ld bytes %s in %0.3Lf seconds (%0.0Lf cps)", bytes, sent?"sent":"received", elapsed / 1000.000, (bytes * 1000) / elapsed); return resp; }