From 37f0c1ae23ad1716403d3d113c3dfdf41c47e329 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 11 Oct 2011 14:08:33 +0200 Subject: [PATCH] client: display summed total of all clients when all stats have been received Signed-off-by: Jens Axboe --- client.c | 23 ++++++++++++++++++++ stat.c | 65 +++++++++++++++++++++++++++++++++++++++----------------- stat.h | 3 +++ 3 files changed, 72 insertions(+), 19 deletions(-) diff --git a/client.c b/client.c index 130aeafc..c40511eb 100644 --- a/client.c +++ b/client.c @@ -66,6 +66,11 @@ static FLIST_HEAD(eta_list); static FLIST_HEAD(arg_list); +static struct thread_stat client_ts; +static struct group_run_stats client_gs; +static int sum_stat_clients; +static int sum_stat_nr; + #define FIO_CLIENT_HASH_BITS 7 #define FIO_CLIENT_HASH_SZ (1 << FIO_CLIENT_HASH_BITS) #define FIO_CLIENT_HASH_MASK (FIO_CLIENT_HASH_SZ - 1) @@ -571,6 +576,20 @@ static void handle_ts(struct fio_net_cmd *cmd) convert_gs(&p->rs, &p->rs); show_thread_status(&p->ts, &p->rs); + + if (sum_stat_clients == 1) + return; + + sum_thread_stats(&client_ts, &p->ts, sum_stat_nr); + sum_group_stats(&client_gs, &p->rs); + + client_ts.members++; + client_ts.groupid = p->ts.groupid; + + if (++sum_stat_nr == sum_stat_clients) { + strcpy(client_ts.name, "All clients"); + show_thread_status(&client_ts, &client_gs); + } } static void handle_gs(struct fio_net_cmd *cmd) @@ -859,6 +878,10 @@ int fio_handle_clients(void) pfds = malloc(nr_clients * sizeof(struct pollfd)); + sum_stat_clients = nr_clients; + init_thread_stat(&client_ts); + init_group_run_stat(&client_gs); + while (!exit_backend && nr_clients) { i = 0; flist_for_each(entry, &client_list) { diff --git a/stat.c b/stat.c index 71eca48e..c2705d26 100644 --- a/stat.c +++ b/stat.c @@ -642,6 +642,26 @@ static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) dst->S.u.f = S; } +void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) +{ + int i; + + for (i = 0; i < 2; i++) { + if (dst->max_run[i] < src->max_run[i]) + dst->max_run[i] = src->max_run[i]; + if (dst->min_run[i] && dst->min_run[i] > src->min_run[i]) + dst->min_run[i] = src->min_run[i]; + if (dst->max_bw[i] < src->max_bw[i]) + dst->max_bw[i] = src->max_bw[i]; + if (dst->min_bw[i] && dst->min_bw[i] > src->min_bw[i]) + dst->min_bw[i] = src->min_bw[i]; + + dst->io_kb[i] += src->io_kb[i]; + dst->agg[i] += src->agg[i]; + } + +} + void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) { int l, k; @@ -691,6 +711,28 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) dst->total_complete += src->total_complete; } +void init_group_run_stat(struct group_run_stats *gs) +{ + memset(gs, 0, sizeof(*gs)); + gs->min_bw[0] = gs->min_run[0] = ~0UL; + gs->min_bw[1] = gs->min_run[1] = ~0UL; +} + +void init_thread_stat(struct thread_stat *ts) +{ + int j; + + memset(ts, 0, sizeof(*ts)); + + for (j = 0; j <= DDIR_WRITE; j++) { + ts->lat_stat[j].min_val = -1UL; + ts->clat_stat[j].min_val = -1UL; + ts->slat_stat[j].min_val = -1UL; + ts->bw_stat[j].min_val = -1UL; + } + ts->groupid = -1; +} + void show_run_stats(void) { struct group_run_stats *runstats, *rs; @@ -701,13 +743,8 @@ void show_run_stats(void) runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1)); - for (i = 0; i < groupid + 1; i++) { - rs = &runstats[i]; - - memset(rs, 0, sizeof(*rs)); - rs->min_bw[0] = rs->min_run[0] = ~0UL; - rs->min_bw[1] = rs->min_run[1] = ~0UL; - } + for (i = 0; i < groupid + 1; i++) + init_group_run_stat(&runstats[i]); /* * find out how many threads stats we need. if group reporting isn't @@ -729,18 +766,8 @@ void show_run_stats(void) threadstats = malloc(nr_ts * sizeof(struct thread_stat)); - for (i = 0; i < nr_ts; i++) { - ts = &threadstats[i]; - - memset(ts, 0, sizeof(*ts)); - for (j = 0; j <= DDIR_WRITE; j++) { - ts->lat_stat[j].min_val = -1UL; - ts->clat_stat[j].min_val = -1UL; - ts->slat_stat[j].min_val = -1UL; - ts->bw_stat[j].min_val = -1UL; - } - ts->groupid = -1; - } + for (i = 0; i < nr_ts; i++) + init_thread_stat(&threadstats[i]); j = 0; last_ts = -1; diff --git a/stat.h b/stat.h index a35f9b1a..3115539f 100644 --- a/stat.h +++ b/stat.h @@ -194,5 +194,8 @@ extern int calc_thread_status(struct jobs_eta *je, int force); extern void display_thread_status(struct jobs_eta *je); extern void show_run_stats(void); extern void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr); +extern void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src); +extern void init_thread_stat(struct thread_stat *ts); +extern void init_group_run_stat(struct group_run_stats *gs); #endif -- 2.25.1