X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;ds=sidebyside;f=stat.c;h=8be4be5761cbfda454da47f541965a67115c6b26;hb=b6cf38f0aed8b12db1c8fd520c09e5a74066ebc9;hp=d95be758334329b0e681347d419522e82ee1cd45;hpb=2b13e716c0921356c0930522718e00b8df34293a;p=fio.git diff --git a/stat.c b/stat.c index d95be758..8be4be57 100644 --- a/stat.c +++ b/stat.c @@ -169,7 +169,7 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p); bw_p = num2str(bw, 6, 1, i2p); - iops = (1000 * ts->total_io_u[ddir]) / runt; + iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt; iops_p = num2str(iops, 6, 1, 0); log_info(" %s: io=%sB, bw=%sB/s, iops=%s, runt=%6llumsec\n", @@ -474,21 +474,28 @@ static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) dst->min_val = min(dst->min_val, src->min_val); dst->max_val = max(dst->max_val, src->max_val); - dst->samples += src->samples; /* - * Needs a new method for calculating stddev, we cannot just - * average them we do below for nr > 1 + * Compute new mean and S after the merge + * */ if (nr == 1) { mean = src->mean; S = src->S; } else { - mean = ((src->mean * (double) (nr - 1)) - + dst->mean) / ((double) nr); - S = ((src->S * (double) (nr - 1)) + dst->S) / ((double) nr); + double delta = src->mean - dst->mean; + + mean = ((src->mean * src->samples) + + (dst->mean * dst->samples)) / + (dst->samples + src->samples); + + S = src->S + dst->S + pow(delta, 2.0) * + (dst->samples * src->samples) / + (dst->samples + src->samples); } + dst->samples += src->samples; dst->mean = mean; dst->S = S; }