simplified reporter callback by removing conditional assignments
This commit is contained in:
parent
7dd1f0cd55
commit
a428063b8b
@ -626,25 +626,16 @@ char *iperf_reporter_callback(struct iperf_test *test)
|
||||
bytes+= ip->bytes_transferred;
|
||||
unit_snprintf(ubuf, UNIT_LEN, (double) (ip->bytes_transferred), test->unit_format);
|
||||
|
||||
if(test->stats_interval <= test->duration && test->stats_interval!= 0)
|
||||
{
|
||||
printf("NORMAL ip->interval_duration = %d \n", ip->interval_duration);
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / test->stats_interval), test->unit_format);
|
||||
}
|
||||
// for duration(t) != multiple(i)
|
||||
else
|
||||
{
|
||||
printf("ELSE ip->interval_duration = %d \n", ip->interval_duration);
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / (test->duration - ip->interval_duration)), test->unit_format);
|
||||
}
|
||||
test->stats_interval = test->stats_interval== 0 ? test->duration : test->stats_interval;
|
||||
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) (ip->bytes_transferred / test->stats_interval), test->unit_format);
|
||||
|
||||
sprintf(message,report_bw_header);
|
||||
strcat(message_final, message);
|
||||
|
||||
if(test->stats_interval!= 0)
|
||||
sprintf(message, report_bw_format, sp->socket, (double)ip->interval_duration, (double)ip->interval_duration + test->stats_interval, ubuf, nbuf);
|
||||
else
|
||||
sprintf(message, report_bw_format, sp->socket, (double)ip->interval_duration, (double)ip->interval_duration + test->duration, ubuf, nbuf);
|
||||
|
||||
strcat(message_final, message);
|
||||
|
||||
sp = sp->next;
|
||||
@ -652,17 +643,12 @@ char *iperf_reporter_callback(struct iperf_test *test)
|
||||
|
||||
unit_snprintf(ubuf, UNIT_LEN, (double) ( bytes), test->unit_format);
|
||||
|
||||
if(test->stats_interval <= test->duration && test->stats_interval!=0)
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) ( bytes / test->stats_interval), test->unit_format);
|
||||
else
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) ( bytes /(test->duration - ip->interval_duration)), test->unit_format);
|
||||
unit_snprintf(nbuf, UNIT_LEN, (double) ( bytes / test->stats_interval), test->unit_format);
|
||||
|
||||
|
||||
if(test->stats_interval!= 0)
|
||||
sprintf(message, report_sum_bw_format, (double)ip->interval_duration,
|
||||
(double)ip->interval_duration + test->stats_interval, ubuf, nbuf);
|
||||
else
|
||||
sprintf(message, report_sum_bw_format, (double)ip->interval_duration,
|
||||
(double)ip->interval_duration + test->duration, ubuf, nbuf);
|
||||
|
||||
strcat(message_final, message);
|
||||
}
|
||||
@ -1047,7 +1033,6 @@ void iperf_run_server(struct iperf_test *test)
|
||||
FD_CLR(test->listener_sock, &test->temp_set);
|
||||
}
|
||||
|
||||
|
||||
//Process the sockets for read operation
|
||||
for (j=0; j< test->max_fd+1; j++)
|
||||
{
|
||||
@ -1225,10 +1210,10 @@ void iperf_run_client(struct iperf_test *test)
|
||||
|
||||
}// while outer timer
|
||||
|
||||
// for last interval
|
||||
test->stats_callback(test);
|
||||
read = test->reporter_callback(test);
|
||||
puts(read);
|
||||
// for last interval
|
||||
test->stats_callback(test);
|
||||
read = test->reporter_callback(test);
|
||||
puts(read);
|
||||
|
||||
// sending STREAM_END packets
|
||||
sp = test->streams;
|
||||
|
Loading…
Reference in New Issue
Block a user