From e24b2709a82043eedafbb7df9186b58fb1b491f6 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Wed, 26 Feb 2003 07:45:21 +0000 Subject: [PATCH] checkin notes, transfer speed fix svn path=/trunk/boinc/; revision=976 --- checkin_notes | 29 +++++++++++++++++++++++++++++ client/net_xfer.C | 12 ++++++++---- client/net_xfer.h | 2 +- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/checkin_notes b/checkin_notes index 43015bfe81..d1079ea31e 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3467,3 +3467,32 @@ David Feb 25 2003 test/ test.inc test_uc.php + +Eric Feb 25, 2003 + - Added net transfer progress. Tracks number of bytes transferred + for file uploads and downloads. + - Fixed Windows battery status bug. + - Net transfer speed measurement in bytes/sec. The measurement decays by + 1/2 every 3 seconds. + - Added PHP function to password protect project admin pages via .htaccess. + - Altered show_message function to specify the project a message is + associated with. + + client/ + client_state.C + cs_scheduler.C + file_xfer.C + net_xfer.C,h + pers_file_xfer.C + mac/ + mac_main.cpp + main.C + message.h + scheduler_op.C + win/ + wingui_mainwindow.cpp + wingui.cpp + hostinfo_win.cpp + test/ + test.inc + diff --git a/client/net_xfer.C b/client/net_xfer.C index ceb48153ad..393ffc5e48 100644 --- a/client/net_xfer.C +++ b/client/net_xfer.C @@ -173,6 +173,7 @@ void NET_XFER::init(char* host, int p, int b) { port = p; blocksize = b; xfer_speed = 0; + recent_bytes = 0; last_speed_update = 0; } @@ -455,19 +456,22 @@ int NET_XFER::do_xfer(int& nbytes_transferred) { } // Update the transfer speed for this NET_XFER -// Decay speed by 1/e every second +// Decay speed by 1/2 every 3 seconds // void NET_XFER::update_speed(int nbytes) { time_t now, delta_t; double x; now = time(0); + recent_bytes += nbytes; if (last_speed_update==0) last_speed_update = now; delta_t = now-last_speed_update; - if (delta_t<=0) delta_t = 0; - x = exp(-(double)delta_t/(double)CLOCKS_PER_SEC); - xfer_speed = (x*xfer_speed)+nbytes; + if (delta_t<=0) return; + x = exp(-delta_t*log(2)/3.0); + xfer_speed *= x; + xfer_speed += recent_bytes*(1-x); last_speed_update = now; + recent_bytes = 0; } void NET_XFER::got_error() { diff --git a/client/net_xfer.h b/client/net_xfer.h index 6f1a9fe453..b4de1018a9 100644 --- a/client/net_xfer.h +++ b/client/net_xfer.h @@ -52,7 +52,7 @@ public: char hostname[256]; int port; int blocksize; - double xfer_speed; // in bytes per second + double xfer_speed,recent_bytes; // in bytes per second clock_t last_speed_update; double bytes_xferred;