diff options
author | jef <jef@odev-vm-4.es.net> | 2012-11-02 09:04:46 -0700 |
---|---|---|
committer | jef <jef@odev-vm-4.es.net> | 2012-11-02 09:04:46 -0700 |
commit | 8a0cc10076bdf74fa3fd70353e6ddeb0968d964c (patch) | |
tree | 03fec06c30624add919ae5e8934f6842cd29b6e1 | |
parent | 99502d9409306af439f5add75efa5ee059e38087 (diff) | |
download | iperf3-8a0cc10076bdf74fa3fd70353e6ddeb0968d964c.tar.gz |
Testing timeval equality deserves to be its own routine.
-rw-r--r-- | src/iperf_api.c | 3 | ||||
-rw-r--r-- | src/timer.c | 9 | ||||
-rw-r--r-- | src/timer.h | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/iperf_api.c b/src/iperf_api.c index 5cad949..d93e515 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1449,8 +1449,7 @@ print_interval_results(struct iperf_test * test, struct iperf_stream * sp) ** else if there's more than one stream, print the separator; ** else nothing. */ - if (sp->result->start_time.tv_sec == ir->interval_start_time.tv_sec && - sp->result->start_time.tv_usec == ir->interval_start_time.tv_usec) + if (timeval_equals(&sp->result->start_time, &ir->interval_start_time)) printf(report_bw_header); else if (test->num_streams > 1) printf(report_bw_separator); diff --git a/src/timer.c b/src/timer.c index 537bdb6..86122f2 100644 --- a/src/timer.c +++ b/src/timer.c @@ -30,6 +30,15 @@ timeval_to_double(struct timeval * tv) return d; } +int +timeval_equals(struct timeval * tv0, struct timeval * tv1) +{ + if ( tv0->tv_sec == tv1->tv_sec && tv0->tv_usec == tv1->tv_usec ) + return 1; + else + return 0; +} + double timeval_diff(struct timeval * tv0, struct timeval * tv1) { diff --git a/src/timer.h b/src/timer.h index aacd218..89cc2f3 100644 --- a/src/timer.h +++ b/src/timer.h @@ -25,6 +25,8 @@ int delay(int64_t ns); double timeval_to_double(struct timeval *tv); +int timeval_equals(struct timeval *tv0, struct timeval *tv1); + double timeval_diff(struct timeval *tv0, struct timeval *tv1); int update_timer(struct timer *tp, time_t sec, suseconds_t usec); |