Add latency bin output to the json output format
authorVincent Fu <vincent.fu@sandisk.com>
Fri, 6 Nov 2015 15:46:44 +0000 (08:46 -0700)
committerJens Axboe <axboe@fb.com>
Fri, 6 Nov 2015 15:46:44 +0000 (08:46 -0700)
We add a new format for this, json+, as it generates a lot of data.
As of now, the only difference between json and json+ is the full
dump of all latency bins.

Signed-off-by: Jens Axboe <axboe@fb.com>
README
fio.1
fio.h
init.c
stat.c

diff --git a/README b/README
index 9d0863d3af4160888e860330e64e66a4610ecb4c..5fa37f3eed33a15a15a38836cf0080edc81688fd 100644 (file)
--- a/README
+++ b/README
@@ -151,7 +151,7 @@ $ fio
        --runtime               Runtime in seconds
        --bandwidth-log         Generate per-job bandwidth logs
        --minimal               Minimal (terse) output
-       --output-format=type    Output format (terse,json,normal)
+       --output-format=type    Output format (terse,json,json+,normal)
        --terse-version=type    Terse version output format (default 3, or 2 or 4).
        --version               Print version info and exit
        --help                  Print this page
diff --git a/fio.1 b/fio.1
index 3bd3318219eef54b9ee55ca2d0179378c2f681a9..140c9bb5356be7f5fc51dfbb040fd01207ef354e 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -21,8 +21,10 @@ list all available tracing options.
 Write output to \fIfilename\fR.
 .TP
 .BI \-\-output-format \fR=\fPformat
-Set the reporting format to \fInormal\fR, \fIterse\fR, or \fIjson\fR.
-Multiple formats can be selected, separate by a comma.
+Set the reporting format to \fInormal\fR, \fIterse\fR, \fIjson\fR, or
+\fIjson+\fR. Multiple formats can be selected, separate by a comma. \fIterse\fR
+is a CSV based format. \fIjson+\fR is like \fIjson\fR, except it adds a full
+dump of the latency buckets.
 .TP
 .BI \-\-runtime \fR=\fPruntime
 Limit run time to \fIruntime\fR seconds.
diff --git a/fio.h b/fio.h
index 8daf9755f34c3bc2b6e9a11c82d5495608e9200e..5e8ac66686d30753519139f80903a4f3a11281d9 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -677,11 +677,13 @@ enum {
        __FIO_OUTPUT_TERSE      = 0,
        __FIO_OUTPUT_JSON       = 1,
        __FIO_OUTPUT_NORMAL     = 2,
-       FIO_OUTPUT_NR           = 3,
+        __FIO_OUTPUT_JSON_PLUS  = 3,
+       FIO_OUTPUT_NR           = 4,
 
        FIO_OUTPUT_TERSE        = 1U << __FIO_OUTPUT_TERSE,
        FIO_OUTPUT_JSON         = 1U << __FIO_OUTPUT_JSON,
        FIO_OUTPUT_NORMAL       = 1U << __FIO_OUTPUT_NORMAL,
+       FIO_OUTPUT_JSON_PLUS    = 1U << __FIO_OUTPUT_JSON_PLUS,
 };
 
 enum {
diff --git a/init.c b/init.c
index 4f5b7dc03dc505cdac2909f3e39524869514414d..e09872f0367940c686392e296107ff11006fd4f5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1766,7 +1766,7 @@ static void usage(const char *name)
        printf("  --runtime\t\tRuntime in seconds\n");
        printf("  --bandwidth-log\tGenerate per-job bandwidth logs\n");
        printf("  --minimal\t\tMinimal (terse) output\n");
-       printf("  --output-format=x\tOutput format (terse,json,normal)\n");
+       printf("  --output-format=x\tOutput format (terse,json,json+,normal)\n");
        printf("  --terse-version=x\tSet terse version output format to 'x'\n");
        printf("  --version\t\tPrint version info and exit\n");
        printf("  --help\t\tPrint this page\n");
@@ -2024,6 +2024,8 @@ static int parse_output_format(const char *optarg)
                        output_format |= FIO_OUTPUT_TERSE;
                else if (!strcmp(opt, "json"))
                        output_format |= FIO_OUTPUT_JSON;
+               else if (!strcmp(opt, "json+"))
+                       output_format |= (FIO_OUTPUT_JSON | FIO_OUTPUT_JSON_PLUS);
                else if (!strcmp(opt, "normal"))
                        output_format |= FIO_OUTPUT_NORMAL;
                else {
diff --git a/stat.c b/stat.c
index 091d6fb1dd1e6a66daa7c0c306737fa2f8312e64..6ee02d32b88432856a7de556f85059d0732bfb81 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -832,7 +832,7 @@ static void add_ddir_status_json(struct thread_stat *ts,
        unsigned int len, minv, maxv;
        int i;
        const char *ddirname[] = {"read", "write", "trim"};
-       struct json_object *dir_object, *tmp_object, *percentile_object;
+       struct json_object *dir_object, *tmp_object, *percentile_object, *clat_bins_object;
        char buf[120];
        double p_of_agg = 100.0;
 
@@ -903,6 +903,18 @@ static void add_ddir_status_json(struct thread_stat *ts,
                json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
        }
 
+       if (output_format & FIO_OUTPUT_JSON_PLUS) {
+               clat_bins_object = json_create_object();
+               json_object_add_value_object(tmp_object, "bins", clat_bins_object);
+               for(i = 0; i < FIO_IO_U_PLAT_NR; i++) {
+                       snprintf(buf, sizeof(buf), "%d", i);
+                       json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+               }
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_BITS", FIO_IO_U_PLAT_BITS);
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_VAL", FIO_IO_U_PLAT_VAL);
+               json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_NR", FIO_IO_U_PLAT_NR);
+       }
+
        if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
                min = max = 0;
                mean = dev = 0.0;