From d170747454857f9ed842cf573327c696bc5831c8 Mon Sep 17 00:00:00 2001 From: Sitsofe Wheeler Date: Tue, 27 Jun 2017 07:21:32 +0100 Subject: [PATCH] stat: further group percentage fixes db84b73bd7b0c3b718596fbeb6a5f940b05a6735 forgot to fix the group percentage calculation when using json or terse output. It also did its caculation after the mean's base might have been changed to bits but the aggregate bandwidth's unit is (k)bytes. Fix these. Signed-off-by: Sitsofe Wheeler --- stat.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/stat.c b/stat.c index beec574d..aebd1071 100644 --- a/stat.c +++ b/stat.c @@ -475,6 +475,12 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, else bw_str = "kB"; + if (rs->agg[ddir]) { + p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); + if (p_of_agg > 100.0) + p_of_agg = 100.0; + } + if (rs->unit_base == 1) { min *= 8.0; max *= 8.0; @@ -482,12 +488,6 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, dev *= 8.0; } - if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); - if (p_of_agg > 100.0) - p_of_agg = 100.0; - } - if (mean > fkb_base * fkb_base) { min /= fkb_base; max /= fkb_base; @@ -924,7 +924,7 @@ static void show_ddir_status_terse(struct thread_stat *ts, double p_of_agg = 100.0; if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) rs->agg[ddir]; + p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); if (p_of_agg > 100.0) p_of_agg = 100.0; } @@ -1055,7 +1055,7 @@ static void add_ddir_status_json(struct thread_stat *ts, if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { if (rs->agg[ddir]) { - p_of_agg = mean * 100 / (double) rs->agg[ddir]; + p_of_agg = mean * 100 / (double) (rs->agg[ddir] / 1024); if (p_of_agg > 100.0) p_of_agg = 100.0; } -- 2.25.1