From 4d658652bac63fd72af8302e27deba5beb381906 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 17 Oct 2011 15:05:47 +0200 Subject: [PATCH 1/1] Add terse version 2 output format 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 --- README | 2 +- fio.1 | 2 +- init.c | 4 ++-- stat.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/README b/README index 26b59099..d41fc660 100644 --- 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 - --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 diff --git a/fio.1 b/fio.1 index aa027dc1..d63d1f2d 100644 --- 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 -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. diff --git a/init.c b/init.c index 72ec85dc..b4127318 100644 --- 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 terse_version = 2; +int terse_version = 3; 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); - if (terse_version != 3) { + if (!(terse_version == 2 || terse_version == 3)) { log_err("fio: bad terse version format\n"); exit_val = 1; do_exit++; diff --git a/stat.c b/stat.c index 19b36961..d54ed2cf 100644 --- 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); } +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" -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]; @@ -723,6 +781,17 @@ static void show_thread_status_terse(struct thread_stat *ts, 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; -- 2.25.1