Add terse version 2 output format
authorJens Axboe <axboe@kernel.dk>
Mon, 17 Oct 2011 13:05:47 +0000 (15:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Oct 2011 13:05:47 +0000 (15:05 +0200)
Default is the new format, but allow a user to set version 2 for
easier backwards compatability with older scripts.

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

diff --git a/README b/README
index 26b59099e5e86886a8255a0a36a34fb7b36d2574..d41fc6601c97adf9e788d8551df20087728f61f0 100644 (file)
--- a/README
+++ b/README
@@ -137,7 +137,7 @@ $ fio
        --bandwidth-log         Generate per-job bandwidth logs
        --minimal               Minimal (terse) output
        --version               Print version info and exit
        --bandwidth-log         Generate per-job bandwidth logs
        --minimal               Minimal (terse) output
        --version               Print version info and exit
-       --terse-version=type    Terse version output format
+       --terse-version=type    Terse version output format (default 3, or 2).
        --help                  Print this page
        --cmdhelp=cmd           Print command help, "all" for all of them
        --showcmd               Turn a job file into command line options
        --help                  Print this page
        --cmdhelp=cmd           Print command help, "all" for all of them
        --showcmd               Turn a job file into command line options
diff --git a/fio.1 b/fio.1
index aa027dc13058bbccf6bc985fa910a3d3e854922a..d63d1f2db56275c82f5216dcdba0128c5e45dd50 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -36,7 +36,7 @@ Print statistics in a terse, semicolon-delimited format.
 Display version information and exit.
 .TP
 .BI \-\-terse\-version \fR=\fPversion
 Display version information and exit.
 .TP
 .BI \-\-terse\-version \fR=\fPversion
-Set terse version output format.
+Set terse version output format (Current version 3, or older version 2).
 .TP
 .B \-\-help
 Display usage information and exit.
 .TP
 .B \-\-help
 Display usage information and exit.
diff --git a/init.c b/init.c
index 72ec85dc740ef08f500662d25c7b7081f2d316f6..b41273181cd5fb6bc8e41941d6267b64975868ee 100644 (file)
--- a/init.c
+++ b/init.c
@@ -54,7 +54,7 @@ char **job_sections = NULL;
 int nr_job_sections = 0;
 char *exec_profile = NULL;
 int warnings_fatal = 0;
 int nr_job_sections = 0;
 char *exec_profile = NULL;
 int warnings_fatal = 0;
-int terse_version = 2;
+int terse_version = 3;
 int is_backend = 0;
 int nr_clients = 0;
 int log_syslog = 0;
 int is_backend = 0;
 int nr_clients = 0;
 int log_syslog = 0;
@@ -1330,7 +1330,7 @@ int parse_cmd_line(int argc, char *argv[])
                        break;
                case 'V':
                        terse_version = atoi(optarg);
                        break;
                case 'V':
                        terse_version = atoi(optarg);
-                       if (terse_version != 3) {
+                       if (!(terse_version == 2 || terse_version == 3)) {
                                log_err("fio: bad terse version format\n");
                                exit_val = 1;
                                do_exit++;
                                log_err("fio: bad terse version format\n");
                                exit_val = 1;
                                do_exit++;
diff --git a/stat.c b/stat.c
index 19b36961aa4854f0e3fb27a692b04ed5f52cb9e9..d54ed2cfeac3c1f4db320f9b913533527a666417 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -660,10 +660,68 @@ static void show_ddir_status_terse(struct thread_stat *ts,
                log_info(";%lu;%lu;%f%%;%f;%f", 0UL, 0UL, 0.0, 0.0, 0.0);
 }
 
                log_info(";%lu;%lu;%f%%;%f;%f", 0UL, 0UL, 0.0, 0.0, 0.0);
 }
 
+static void show_thread_status_terse_v2(struct thread_stat *ts,
+                                       struct group_run_stats *rs)
+{
+       double io_u_dist[FIO_IO_U_MAP_NR];
+       double io_u_lat_u[FIO_IO_U_LAT_U_NR];
+       double io_u_lat_m[FIO_IO_U_LAT_M_NR];
+       double usr_cpu, sys_cpu;
+       int i;
+
+       /* General Info */
+       log_info("2;%s;%d;%d", ts->name, ts->groupid, ts->error);
+       /* Log Read Status */
+       show_ddir_status_terse(ts, rs, 0);
+       /* Log Write Status */
+       show_ddir_status_terse(ts, rs, 1);
+
+       /* CPU Usage */
+       if (ts->total_run_time) {
+               double runt = (double) ts->total_run_time;
+
+               usr_cpu = (double) ts->usr_time * 100 / runt;
+               sys_cpu = (double) ts->sys_time * 100 / runt;
+       } else {
+               usr_cpu = 0;
+               sys_cpu = 0;
+       }
+
+       log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf,
+                                                               ts->minf);
+
+       /* Calc % distribution of IO depths, usecond, msecond latency */
+       stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
+       stat_calc_lat_u(ts, io_u_lat_u);
+       stat_calc_lat_m(ts, io_u_lat_m);
+
+       /* Only show fixed 7 I/O depth levels*/
+       log_info(";%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%",
+                       io_u_dist[0], io_u_dist[1], io_u_dist[2], io_u_dist[3],
+                       io_u_dist[4], io_u_dist[5], io_u_dist[6]);
+
+       /* Microsecond latency */
+       for (i = 0; i < FIO_IO_U_LAT_U_NR; i++)
+               log_info(";%3.2f%%", io_u_lat_u[i]);
+       /* Millisecond latency */
+       for (i = 0; i < FIO_IO_U_LAT_M_NR; i++)
+               log_info(";%3.2f%%", io_u_lat_m[i]);
+       /* Additional output if continue_on_error set - default off*/
+       if (ts->continue_on_error)
+               log_info(";%lu;%d", ts->total_err_count, ts->first_error);
+       log_info("\n");
+
+       /* Additional output if description is set */
+       if (ts->description)
+               log_info(";%s", ts->description);
+
+       log_info("\n");
+}
+
 #define FIO_TERSE_VERSION      "3"
 
 #define FIO_TERSE_VERSION      "3"
 
-static void show_thread_status_terse(struct thread_stat *ts,
-                                    struct group_run_stats *rs)
+static void show_thread_status_terse_v3(struct thread_stat *ts,
+                                       struct group_run_stats *rs)
 {
        double io_u_dist[FIO_IO_U_MAP_NR];
        double io_u_lat_u[FIO_IO_U_LAT_U_NR];
 {
        double io_u_dist[FIO_IO_U_MAP_NR];
        double io_u_lat_u[FIO_IO_U_LAT_U_NR];
@@ -723,6 +781,17 @@ static void show_thread_status_terse(struct thread_stat *ts,
                log_info(";%s", ts->description);
 }
 
                log_info(";%s", ts->description);
 }
 
+static void show_thread_status_terse(struct thread_stat *ts,
+                                    struct group_run_stats *rs)
+{
+       if (terse_version == 2)
+               show_thread_status_terse_v2(ts, rs);
+       else if (terse_version == 3)
+               show_thread_status_terse_v3(ts, rs);
+       else
+               log_err("fio: bad terse version!? %d\n", terse_version);
+}
+
 static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr)
 {
        double mean, S;
 static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr)
 {
        double mean, S;