X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=jam.c;fp=jam.c;h=1b6aaed6cf7625462f638d86eaa9430a5212b585;hb=f4c2815e7f939daf638b8cd388a212c9278f341c;hp=7e46c21a48b5e50313d122eba00d0dfb7916197e;hpb=86e150e0c44395555a9f56d23170cf0f87f151d0;p=jam diff --git a/jam.c b/jam.c index 7e46c21..1b6aaed 100644 --- a/jam.c +++ b/jam.c @@ -217,11 +217,13 @@ void *receiver_worker(void *arg) if (ret == 0) break; + bytes_received += ret; + // update the central counter after every 1MB (8ms // at gigabit speeds, should be enough) of received data if (bytes_received > 1048576) { pthread_mutex_lock(&receive_mutex); - total_bytes_sent += bytes_received; + total_bytes_received += bytes_received; pthread_mutex_unlock(&receive_mutex); bytes_received = 0; @@ -372,7 +374,22 @@ int main(int argc, char **argv) } } - sleep(3600); + // Just stay around collecting statistics until we're done. + for ( ;; ) { + unsigned long long sent, received; + + pthread_mutex_lock(&send_mutex); + sent = total_bytes_sent; + pthread_mutex_unlock(&send_mutex); + + pthread_mutex_lock(&receive_mutex); + received = total_bytes_received; + pthread_mutex_unlock(&receive_mutex); + + printf("%llu %llu\n", sent, received); + + sleep(1); + } exit(0); }