1
1

Fix stats for multiple streams from Alexey Zaytsev <alexey.zaytsev@gmail.com>

Этот коммит содержится в:
Jon Dugan 2011-05-02 23:09:06 +00:00
родитель 7d375156aa
Коммит 94d391af37

Просмотреть файл

@ -1195,36 +1195,23 @@ iperf_stats_callback(struct iperf_test * test)
} }
/**************************************************************************/ static void
iperf_print_intermediate(struct iperf_test *test)
/**
* iperf_reporter_callback -- handles the report printing
*
*/
void
iperf_reporter_callback(struct iperf_test * test)
{ {
int total_packets = 0, lost_packets = 0;
char ubuf[UNIT_LEN]; char ubuf[UNIT_LEN];
char nbuf[UNIT_LEN]; char nbuf[UNIT_LEN];
struct iperf_stream *sp = NULL; struct iperf_stream *sp = NULL;
iperf_size_t bytes = 0, bytes_sent = 0, bytes_received = 0; iperf_size_t bytes = 0, bytes_sent = 0, bytes_received = 0;
iperf_size_t total_sent = 0, total_received = 0;
double start_time, end_time, avg_jitter; double start_time, end_time, avg_jitter;
struct iperf_interval_results *ip = NULL; struct iperf_interval_results *ip = NULL;
switch (test->state) {
case TEST_RUNNING:
case STREAM_RUNNING:
/* print interval results for each stream */
SLIST_FOREACH(sp, &test->streams, streams) { SLIST_FOREACH(sp, &test->streams, streams) {
print_interval_results(test, sp); print_interval_results(test, sp);
bytes += sp->result->interval_results->bytes_transferred; /* sum up all streams */ bytes += sp->result->last_interval_results->bytes_transferred; /* sum up all streams */
} }
if (bytes <=0 ) { /* this can happen if timer goes off just when client exits */ if (bytes <=0 ) { /* this can happen if timer goes off just when client exits */
fprintf(stderr, "error: bytes <= 0!\n"); fprintf(stderr, "error: bytes <= 0!\n");
break; return;
} }
/* next build string with sum of all streams */ /* next build string with sum of all streams */
if (test->num_streams > 1) { if (test->num_streams > 1) {
@ -1239,11 +1226,23 @@ iperf_reporter_callback(struct iperf_test * test)
end_time = timeval_diff(&sp->result->start_time,&ip->interval_end_time); end_time = timeval_diff(&sp->result->start_time,&ip->interval_end_time);
printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf); printf(report_sum_bw_format, start_time, end_time, ubuf, nbuf);
} }
if (test->tcp_info) if (test->tcp_info) {
print_tcpinfo(test); print_tcpinfo(test);
// print_tcpinfo(ip); }
break; }
case DISPLAY_RESULTS:
static void
iperf_print_results (struct iperf_test *test)
{
int total_packets = 0, lost_packets = 0;
char ubuf[UNIT_LEN];
char nbuf[UNIT_LEN];
struct iperf_stream *sp = NULL;
iperf_size_t bytes = 0, bytes_sent = 0, bytes_received = 0;
iperf_size_t total_sent = 0, total_received = 0;
double start_time, end_time, avg_jitter;
struct iperf_interval_results *ip = NULL;
/* print final summary for all intervals */ /* print final summary for all intervals */
printf(report_bw_header); printf(report_bw_header);
@ -1269,8 +1268,6 @@ iperf_reporter_callback(struct iperf_test * test)
if (test->protocol->id == Ptcp) { if (test->protocol->id == Ptcp) {
printf(" Sent\n"); printf(" Sent\n");
printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf); printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
} else { } else {
printf(report_bw_jitter_loss_format, sp->socket, start_time, printf(report_bw_jitter_loss_format, sp->socket, start_time,
end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error, end_time, ubuf, nbuf, sp->jitter * 1000, sp->cnt_error,
@ -1310,8 +1307,6 @@ iperf_reporter_callback(struct iperf_test * test)
} }
if (test->tcp_info) { if (test->tcp_info) {
// ip = sp->result->last_interval_results;
// print_tcpinfo(ip);
print_tcpinfo(test); print_tcpinfo(test);
} }
@ -1319,7 +1314,36 @@ iperf_reporter_callback(struct iperf_test * test)
printf("Host CPU Utilization: %.1f%%\n", test->cpu_util); printf("Host CPU Utilization: %.1f%%\n", test->cpu_util);
printf("Remote CPU Utilization: %.1f%%\n", test->remote_cpu_util); printf("Remote CPU Utilization: %.1f%%\n", test->remote_cpu_util);
} }
}
/**************************************************************************/
/**
* iperf_reporter_callback -- handles the report printing
*
*/
void
iperf_reporter_callback(struct iperf_test * test)
{
int total_packets = 0, lost_packets = 0;
char ubuf[UNIT_LEN];
char nbuf[UNIT_LEN];
struct iperf_stream *sp = NULL;
iperf_size_t bytes = 0, bytes_sent = 0, bytes_received = 0;
iperf_size_t total_sent = 0, total_received = 0;
double start_time, end_time, avg_jitter;
struct iperf_interval_results *ip = NULL;
switch (test->state) {
case TEST_RUNNING:
case STREAM_RUNNING:
/* print interval results for each stream */
iperf_print_intermediate(test);
break;
case DISPLAY_RESULTS:
iperf_print_intermediate(test);
iperf_print_results(test);
break; break;
} }