Skip to content

Commit

Permalink
Merge pull request #255 from pspacek/reword-conn-stats
Browse files Browse the repository at this point in the history
Reword connection statistics
  • Loading branch information
jelu authored Sep 15, 2023
2 parents dc70f80 + a80de21 commit c717956
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/dnsperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ typedef struct {
uint64_t latency_min;
uint64_t latency_max;

uint64_t num_conn_reconnect;
uint64_t num_conn_attempts;
uint64_t num_conn_completed;

uint64_t conn_latency_sum;
Expand Down Expand Up @@ -294,7 +294,7 @@ diff_stats(const config_t* config, stats_t* last, stats_t* now, stats_t* diff)
diff->latency_min = 0; /* not enough data */
diff->latency_max = 0;

diff->num_conn_reconnect = now->num_conn_reconnect - last->num_conn_reconnect;
diff->num_conn_attempts = now->num_conn_attempts - last->num_conn_attempts;
diff->num_conn_completed = now->num_conn_completed - last->num_conn_completed;

diff->conn_latency_sum = now->conn_latency_sum - last->conn_latency_sum;
Expand Down Expand Up @@ -438,16 +438,16 @@ print_statistics(const config_t* config, const times_t* times, stats_t* stats, u

printf("\n");

if (!stats->num_conn_completed && !stats->num_conn_reconnect) {
if (!stats->num_conn_completed && !stats->num_conn_attempts) {
fflush(stdout);
return;
}

printf("Connection Statistics:\n\n");
printf(" Reconnections: %" PRIu64 " (%.2lf%% of %" PRIu64 " connections)\n\n",
stats->num_conn_reconnect,
PERF_SAFE_DIV(100.0 * stats->num_conn_reconnect, stats->num_conn_completed),
stats->num_conn_completed);
printf(" Connection attempts: %" PRIu64 " (%" PRIu64 " successful, %.2lf%%)\n\n",
stats->num_conn_attempts,
stats->num_conn_completed,
PERF_SAFE_DIV(100.0 * stats->num_conn_completed, stats->num_conn_attempts));
latency_avg = PERF_SAFE_DIV(stats->conn_latency_sum, stats->num_conn_completed);
printf(" Average Latency (s): %u.%06u",
(unsigned int)(latency_avg / MILLION),
Expand Down Expand Up @@ -518,7 +518,7 @@ sum_stats(const config_t* config, stats_t* total)
total->latency_max = stats->latency_max;

total->num_conn_completed += stats->num_conn_completed;
total->num_conn_reconnect += stats->num_conn_reconnect;
total->num_conn_attempts += stats->num_conn_attempts;

total->conn_latency_sum += stats->conn_latency_sum;
total->conn_latency_sum_squares += stats->conn_latency_sum_squares;
Expand Down Expand Up @@ -1502,7 +1502,8 @@ static void perf__net_event(struct perf_net_socket* sock, perf_socket_event_t ev
break;

case perf_socket_event_reconnecting:
stats->num_conn_reconnect++;
case perf_socket_event_connecting:
stats->num_conn_attempts++;
break;

default:
Expand Down
14 changes: 10 additions & 4 deletions src/resperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ static uint64_t num_queries_outstanding;
static uint64_t num_responses_received;
static uint64_t num_queries_timed_out;
static uint64_t rcodecounts[16];
static uint64_t num_reconnections;
static uint64_t num_conn_completed;
static uint64_t num_conn_attempts;

static uint64_t time_now;
static uint64_t time_of_program_start;
Expand Down Expand Up @@ -489,10 +490,12 @@ static void perf__net_event(struct perf_net_socket* sock, perf_socket_event_t ev
case perf_socket_event_connected:
b->connections++;
b->conn_latency_sum += elapsed_time / (double)MILLION;
num_conn_completed++;
break;

case perf_socket_event_reconnecting:
num_reconnections++;
case perf_socket_event_connecting:
num_conn_attempts++;
break;

default:
Expand Down Expand Up @@ -545,8 +548,7 @@ print_statistics(void)
perf_dns_rcode_strings[i], rcodecounts[i],
(rcodecounts[i] * 100.0) / num_responses_received);
}
printf("\n");
printf(" Reconnection(s): %" PRIu64 "\n", num_reconnections);
printf("\n\n");
printf(" Run time (s): %u.%06u\n",
(unsigned int)(run_time / MILLION),
(unsigned int)(run_time % MILLION));
Expand All @@ -569,6 +571,10 @@ print_statistics(void)
printf(" Maximum throughput: %.6lf qps\n", max_throughput);
printf(" Lost at that point: %.2f%%\n", loss_at_max_throughput);
printf("\n");
printf(" Connection attempts: %" PRIu64 " (%" PRIu64 " successful, %.2lf%%)\n\n",
num_conn_attempts,
num_conn_completed,
PERF_SAFE_DIV(100.0 * num_conn_completed, num_conn_attempts));
}

/*
Expand Down

0 comments on commit c717956

Please sign in to comment.