// Total number of open connections
unsigned int connections;
+
+ size_t bytes_sent;
+ size_t total_bytes_sent;
};
// Set to one when the timeout has expired
// Format timestamp
const char* timestamp = format_timespec(&now);
- INFO( conf, "--- %s --------------------\n", timestamp);
+ // Format total bytes sent
+ char* total_bytes_sent = format_size(stats->total_bytes_sent, FIREPERF_FORMAT_BYTES);
+
+ // Calculate bandwidth
+ char* bps = format_size(stats->bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS);
+
+ INFO(conf, "--- %s --------------------\n", timestamp);
+ INFO(conf, " %-20s: %18s/s\n", "Current Bandwidth", bps);
+ INFO(conf, " %-20s: %20s\n", "Total Bytes Sent", total_bytes_sent);
// Remember when this was printed last
stats->last_printed = now;
+ // Reset statistics
+ stats->bytes_sent = 0;
+
+ // Cleanup
+ if (bps)
+ free(bps);
+
+ if (total_bytes_sent)
+ free(total_bytes_sent);
+
return 0;
}
return -1;
}
-static int send_data_to_server(struct fireperf_config* conf, int fd,
- struct fireperf_random_pool* pool) {
+static int send_data_to_server(struct fireperf_config* conf,
+ struct fireperf_client_stats* stats, int fd, struct fireperf_random_pool* pool) {
const char* buffer = ZERO;
ssize_t bytes_sent;
DEBUG(conf, "bytes_sent = %zu\n", bytes_sent);
+ // Update statistics
+ stats->bytes_sent += bytes_sent;
+ stats->total_bytes_sent += bytes_sent;
+
return 0;
}
stats.connections--;
} else if (events[i].events & EPOLLOUT) {
- r = send_data_to_server(conf, fd, pool);
+ r = send_data_to_server(conf, &stats, fd, pool);
if (r)
goto ERROR;
}