Testing timeval equality deserves to be its own routine.

This commit is contained in:
jef 2012-11-02 09:04:46 -07:00
parent 99502d9409
commit 8a0cc10076
3 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -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);