From 77473ab378ce2eff9a13f4df2b5ae27dc062e34c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 24 Sep 2024 14:42:16 +0000 Subject: [PATCH] stats: Drop the unused stats dump function Signed-off-by: Michael Tremer --- src/ctx.c | 18 ------------------ src/ctx.h | 2 -- src/stats.c | 52 ---------------------------------------------------- src/stats.h | 6 ------ src/tui.h | 3 +++ 5 files changed, 3 insertions(+), 78 deletions(-) diff --git a/src/ctx.c b/src/ctx.c index 501d750..91b77be 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -419,21 +419,3 @@ struct fireperf_stats fireperf_ctx_get_stats(struct fireperf_ctx* ctx) { return stats; } - -int fireperf_ctx_dump_stats(struct fireperf_ctx* ctx) { - struct fireperf_stats stats = {}; - int r; - - // Fetch the current stats - stats = fireperf_ctx_get_stats(ctx); - - // Dump the stats - r = fireperf_stats_dump(ctx, &ctx->stats, &stats); - if (r) - return r; - - // Replace the stats for the next iteration - ctx->stats = stats; - - return 0; -} diff --git a/src/ctx.h b/src/ctx.h index 2bc601f..ed156f9 100644 --- a/src/ctx.h +++ b/src/ctx.h @@ -74,6 +74,4 @@ void fireperf_ctx_free(struct fireperf_ctx* ctx); struct fireperf_worker* fireperf_ctx_fetch_worker(struct fireperf_ctx* ctx); struct fireperf_stats fireperf_ctx_get_stats(struct fireperf_ctx* ctx); -int fireperf_ctx_dump_stats(struct fireperf_ctx* ctx); - #endif /* FIREPERF_CTX_H */ diff --git a/src/stats.c b/src/stats.c index 46a94f6..1e95642 100644 --- a/src/stats.c +++ b/src/stats.c @@ -42,55 +42,3 @@ struct fireperf_stats fireperf_stats_step( return stats; } - -int fireperf_stats_dump(struct fireperf_ctx* ctx, - struct fireperf_stats* old, struct fireperf_stats* new) { - // Compute the delta since the last dump - double delta = timespec_delta(&new->t, &old->t); - - // Called too soon again? - if (delta < 0.1) - return 0; - - // Compute the changes - const struct fireperf_stats stats = fireperf_stats_step(old, new); - - // Format timestamp - const char* timestamp = format_timespec(&stats.t); - - INFO(ctx, "--- %s -------------------------\n", timestamp); - INFO(ctx, " : %12s %12s\n", "RX", "TX"); - INFO(ctx, " %-20s: %25u\n", "Open Connection(s)", stats.open_connections); - INFO(ctx, " %-20s: %23.2f/s\n", "New Connections", stats.connections / delta); - - // Show current bandwidth - char* bps_received = format_size(stats.bytes_received * 8 / delta, FIREPERF_FORMAT_BITS); - char* bps_sent = format_size(stats.bytes_sent * 8 / delta, FIREPERF_FORMAT_BITS); - - if (bps_received || bps_sent) { - INFO(ctx, " %-20s: %10s/s %10s/s\n", "Current Bandwidth", bps_received, bps_sent); - - if (bps_received) - free(bps_received); - if (bps_sent) - free(bps_sent); - } - - // Total bytes - char* total_bytes_received = format_size(stats.total_bytes_received, FIREPERF_FORMAT_BYTES); - char* total_bytes_sent = format_size(stats.total_bytes_sent, FIREPERF_FORMAT_BYTES); - - if (total_bytes_received || total_bytes_sent) { - INFO(ctx, " %-20s: %12s %12s\n", "Total Bytes", total_bytes_received, total_bytes_sent); - - if (total_bytes_received) - free(total_bytes_received); - if (total_bytes_sent) - free(total_bytes_sent); - } - - // Empty line - INFO(ctx, "\n"); - - return 0; -} diff --git a/src/stats.h b/src/stats.h index d15f49c..577ac52 100644 --- a/src/stats.h +++ b/src/stats.h @@ -40,13 +40,7 @@ struct fireperf_stats { size_t total_bytes_sent; }; -// Forward declararion -struct fireperf_ctx; - struct fireperf_stats fireperf_stats_step( const struct fireperf_stats* old, const struct fireperf_stats* new); -int fireperf_stats_dump(struct fireperf_ctx* ctx, - struct fireperf_stats* old, struct fireperf_stats* new); - #endif /* FIREPERF_STATS_H */ diff --git a/src/tui.h b/src/tui.h index 6d29bc6..a210a43 100644 --- a/src/tui.h +++ b/src/tui.h @@ -26,6 +26,9 @@ struct fireperf_tui; #include "ctx.h" #include "stats.h" +// Forward declaration +struct fireperf_ctx; + int fireperf_tui_init(struct fireperf_tui** tui, struct fireperf_ctx* ctx); void fireperf_tui_finish(struct fireperf_tui* tui); -- 2.47.2