stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent
authorVincent Fu <vincent.fu@wdc.com>
Thu, 7 Feb 2019 15:51:07 +0000 (10:51 -0500)
committerJens Axboe <axboe@kernel.dk>
Thu, 7 Feb 2019 16:48:46 +0000 (09:48 -0700)
In the JSON output, the 'percentiles' object currently always appears within the
'clat_ns' object. Put it inside the 'lat_ns' object when --lat_percentiles=1 is set.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
stat.c

diff --git a/stat.c b/stat.c
index 7c843e6b1423497ba3b0bf6b44227285d9c1e6c7..c1f46e1d43f34fe9a8988279780c269162d9084d 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1088,7 +1088,8 @@ static void add_ddir_status_json(struct thread_stat *ts,
                len = 0;
 
        percentile_object = json_create_object();
                len = 0;
 
        percentile_object = json_create_object();
-       json_object_add_value_object(tmp_object, "percentile", percentile_object);
+       if (ts->clat_percentiles)
+               json_object_add_value_object(tmp_object, "percentile", percentile_object);
        for (i = 0; i < len; i++) {
                snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
                json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
        for (i = 0; i < len; i++) {
                snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
                json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
@@ -1127,6 +1128,8 @@ static void add_ddir_status_json(struct thread_stat *ts,
        json_object_add_value_int(tmp_object, "max", max);
        json_object_add_value_float(tmp_object, "mean", mean);
        json_object_add_value_float(tmp_object, "stddev", dev);
        json_object_add_value_int(tmp_object, "max", max);
        json_object_add_value_float(tmp_object, "mean", mean);
        json_object_add_value_float(tmp_object, "stddev", dev);
+       if (ts->lat_percentiles)
+               json_object_add_value_object(tmp_object, "percentile", percentile_object);
        if (output_format & FIO_OUTPUT_JSON_PLUS && ts->lat_percentiles)
                json_object_add_value_object(tmp_object, "bins", clat_bins_object);
 
        if (output_format & FIO_OUTPUT_JSON_PLUS && ts->lat_percentiles)
                json_object_add_value_object(tmp_object, "bins", clat_bins_object);