X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=stat.c;h=ca066175d94243f51d7bd2773f0de1b4982c1fa1;hb=f77d4b73613adbce2177576afd591a3322774329;hp=e5ec22374b8c2d410fdfa1e841ba93c0ad8ecd08;hpb=210dd0fc66b8956065e098bb9314febe8993e849;p=fio.git diff --git a/stat.c b/stat.c index e5ec2237..ca066175 100644 --- a/stat.c +++ b/stat.c @@ -1104,7 +1104,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts, json_object_add_value_int(root, "error", ts->error); /* ETA Info */ - je = get_jobs_eta(1, &size); + je = get_jobs_eta(true, &size); if (je) { json_object_add_value_int(root, "eta", je->eta_sec); json_object_add_value_int(root, "elapsed", je->elapsed_sec); @@ -1253,7 +1253,7 @@ struct json_object *show_thread_status(struct thread_stat *ts, return ret; } -static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) +static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first) { double mean, S; @@ -1268,7 +1268,7 @@ static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) * */ - if (nr == 1) { + if (first) { mean = src->mean.u.f; S = src->S.u.f; } else { @@ -1312,31 +1312,38 @@ void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) dst->unit_base = src->unit_base; } -void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) +void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, + bool first) { int l, k; for (l = 0; l < DDIR_RWDIR_CNT; l++) { if (!dst->unified_rw_rep) { - sum_stat(&dst->clat_stat[l], &src->clat_stat[l], nr); - sum_stat(&dst->slat_stat[l], &src->slat_stat[l], nr); - sum_stat(&dst->lat_stat[l], &src->lat_stat[l], nr); - sum_stat(&dst->bw_stat[l], &src->bw_stat[l], nr); + sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first); + sum_stat(&dst->slat_stat[l], &src->slat_stat[l], first); + sum_stat(&dst->lat_stat[l], &src->lat_stat[l], first); + sum_stat(&dst->bw_stat[l], &src->bw_stat[l], first); dst->io_bytes[l] += src->io_bytes[l]; if (dst->runtime[l] < src->runtime[l]) dst->runtime[l] = src->runtime[l]; } else { - sum_stat(&dst->clat_stat[0], &src->clat_stat[l], nr); - sum_stat(&dst->slat_stat[0], &src->slat_stat[l], nr); - sum_stat(&dst->lat_stat[0], &src->lat_stat[l], nr); - sum_stat(&dst->bw_stat[0], &src->bw_stat[l], nr); + sum_stat(&dst->clat_stat[0], &src->clat_stat[l], first); + sum_stat(&dst->slat_stat[0], &src->slat_stat[l], first); + sum_stat(&dst->lat_stat[0], &src->lat_stat[l], first); + sum_stat(&dst->bw_stat[0], &src->bw_stat[l], first); dst->io_bytes[0] += src->io_bytes[l]; if (dst->runtime[0] < src->runtime[l]) dst->runtime[0] = src->runtime[l]; + + /* + * We're summing to the same destination, so override + * 'first' after the first iteration of the loop + */ + first = false; } } @@ -1531,7 +1538,7 @@ void __show_run_stats(void) for (k = 0; k < ts->nr_block_infos; k++) ts->block_infos[k] = td->ts.block_infos[k]; - sum_thread_stats(ts, &td->ts, idx); + sum_thread_stats(ts, &td->ts, idx == 1); } for (i = 0; i < nr_ts; i++) {