Add unified_rw_reporting option
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 8e1034b513fd162dbc539eacdcf2640cfa4ff88d..5cc6b7b91417f13a6416da4844a7bbfa4e9230d0 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -277,9 +277,9 @@ void show_group_stats(struct group_run_stats *rs)
                p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p);
 
                log_info("%s: io=%sB, aggrb=%sB/s, minb=%sB/s, maxb=%sB/s,"
                p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p);
 
                log_info("%s: io=%sB, aggrb=%sB/s, minb=%sB/s, maxb=%sB/s,"
-                        " mint=%llumsec, maxt=%llumsec\n", ddir_str[i], p1, p2,
-                                               p3, p4, rs->min_run[i],
-                                               rs->max_run[i]);
+                        " mint=%llumsec, maxt=%llumsec\n",
+                               rs->unified_rw_rep ? "  MIXED" : ddir_str[i],
+                               p1, p2, p3, p4, rs->min_run[i], rs->max_run[i]);
 
                free(p1);
                free(p2);
 
                free(p1);
                free(p2);
@@ -381,8 +381,8 @@ static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
        iops_p = num2str(iops, 6, 1, 0);
 
        log_info("  %s: io=%sB, bw=%sB/s, iops=%s, runt=%6llumsec\n",
        iops_p = num2str(iops, 6, 1, 0);
 
        log_info("  %s: io=%sB, bw=%sB/s, iops=%s, runt=%6llumsec\n",
-                                       ddir_str[ddir], io_p, bw_p, iops_p,
-                                       ts->runtime[ddir]);
+                               rs->unified_rw_rep ? "mixed" : ddir_str[ddir],
+                               io_p, bw_p, iops_p, ts->runtime[ddir]);
 
        free(io_p);
        free(bw_p);
 
        free(io_p);
        free(bw_p);
@@ -695,8 +695,12 @@ static void add_ddir_status_json(struct thread_stat *ts,
 
        assert(ddir_rw(ddir));
 
 
        assert(ddir_rw(ddir));
 
+       if (ts->unified_rw_rep && ddir != DDIR_READ)
+               return;
+
        dir_object = json_create_object();
        dir_object = json_create_object();
-       json_object_add_value_object(parent, ddirname[ddir], dir_object);
+       json_object_add_value_object(parent,
+               ts->unified_rw_rep ? "mixed" : ddirname[ddir], dir_object);
 
        iops = bw = 0;
        if (ts->runtime[ddir]) {
 
        iops = bw = 0;
        if (ts->runtime[ddir]) {
@@ -1062,15 +1066,27 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr)
        int l, k;
 
        for (l = 0; l < DDIR_RWDIR_CNT; l++) {
        int l, k;
 
        for (l = 0; l < DDIR_RWDIR_CNT; l++) {
-               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);
-
-               dst->io_bytes[l] += src->io_bytes[l];
-
-               if (dst->runtime[l] < src->runtime[l])
-                       dst->runtime[l] = src->runtime[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);
+
+                       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);
+
+                       dst->io_bytes[0] += src->io_bytes[l];
+
+                       if (dst->runtime[0] < src->runtime[l])
+                               dst->runtime[0] = src->runtime[l];
+               }
        }
 
        dst->usr_time += src->usr_time;
        }
 
        dst->usr_time += src->usr_time;
@@ -1091,14 +1107,24 @@ void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr)
                dst->io_u_lat_m[k] += src->io_u_lat_m[k];
 
        for (k = 0; k < DDIR_RWDIR_CNT; k++) {
                dst->io_u_lat_m[k] += src->io_u_lat_m[k];
 
        for (k = 0; k < DDIR_RWDIR_CNT; k++) {
-               dst->total_io_u[k] += src->total_io_u[k];
-               dst->short_io_u[k] += src->short_io_u[k];
+               if (!dst->unified_rw_rep) {
+                       dst->total_io_u[k] += src->total_io_u[k];
+                       dst->short_io_u[k] += src->short_io_u[k];
+               } else {
+                       dst->total_io_u[0] += src->total_io_u[k];
+                       dst->short_io_u[0] += src->short_io_u[k];
+               }
        }
 
        for (k = 0; k < DDIR_RWDIR_CNT; k++) {
                int m;
        }
 
        for (k = 0; k < DDIR_RWDIR_CNT; k++) {
                int m;
-               for (m = 0; m < FIO_IO_U_PLAT_NR; m++)
-                       dst->io_u_plat[k][m] += src->io_u_plat[k][m];
+
+               for (m = 0; m < FIO_IO_U_PLAT_NR; m++) {
+                       if (!dst->unified_rw_rep)
+                               dst->io_u_plat[k][m] += src->io_u_plat[k][m];
+                       else
+                               dst->io_u_plat[0][m] += src->io_u_plat[k][m];
+               }
        }
 
        dst->total_run_time += src->total_run_time;
        }
 
        dst->total_run_time += src->total_run_time;
@@ -1210,6 +1236,7 @@ void show_run_stats(void)
                        ts->pid = td->pid;
 
                        ts->kb_base = td->o.kb_base;
                        ts->pid = td->pid;
 
                        ts->kb_base = td->o.kb_base;
+                       ts->unified_rw_rep = td->o.unified_rw_rep;
                } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
                        log_info("fio: kb_base differs for jobs in group, using"
                                 " %u as the base\n", ts->kb_base);
                } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
                        log_info("fio: kb_base differs for jobs in group, using"
                                 " %u as the base\n", ts->kb_base);
@@ -1239,6 +1266,7 @@ void show_run_stats(void)
                ts = &threadstats[i];
                rs = &runstats[ts->groupid];
                rs->kb_base = ts->kb_base;
                ts = &threadstats[i];
                rs = &runstats[ts->groupid];
                rs->kb_base = ts->kb_base;
+               rs->unified_rw_rep += ts->unified_rw_rep;
 
                for (j = 0; j < DDIR_RWDIR_CNT; j++) {
                        if (!ts->runtime[j])
 
                for (j = 0; j < DDIR_RWDIR_CNT; j++) {
                        if (!ts->runtime[j])