From eef02441621aa969f01a1a331e0215dd587d25af Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 6 Feb 2013 08:51:57 +0100 Subject: [PATCH] Handle normal output wrapping of the percentile list Signed-off-by: Jens Axboe --- parse.c | 7 ++++--- stat.c | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/parse.c b/parse.c index 12a35bdc..51cefcae 100644 --- a/parse.c +++ b/parse.c @@ -369,11 +369,10 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, long ul1, ul2; double uf; char **cp = NULL; - char *cp2; int ret = 0, is_time = 0; const struct value_pair *vp; struct value_pair posval[PARSE_MAX_VP]; - int i, len, all_skipped = 1; + int i, all_skipped = 1; dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name, o->type, ptr); @@ -503,6 +502,8 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, break; } case FIO_OPT_FLOAT_LIST: { + char *cp2; + if (first) { /* ** Initialize precision to 0 and zero out list @@ -546,7 +547,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, */ cp2 = strchr(ptr, '.'); if (cp2 != NULL) { - len = 0; + int len = 0; while (*++cp2 != '\0' && *cp2 >= '0' && *cp2 <= '9') len++; diff --git a/stat.c b/stat.c index 8bcd566e..28acc233 100644 --- a/stat.c +++ b/stat.c @@ -186,8 +186,8 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, { unsigned int len, j = 0, minv, maxv; unsigned int *ovals; - int is_last, scale_down; - char buf[32]; + int is_last, per_line, scale_down; + char fmt[32]; len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv); if (!len) @@ -205,13 +205,14 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, log_info(" clat percentiles (usec):\n |"); } - snprintf(buf, sizeof(buf), "%%1.%luf", precision); + snprintf(fmt, sizeof(fmt), "%%1.%luf", precision); + per_line = (80 - 7) / (precision + 14); for (j = 0; j < len; j++) { char fbuf[16], *ptr = fbuf; /* for formatting */ - if (j != 0 && (j % 4) == 0) + if (j != 0 && (j % per_line) == 0) log_info(" |"); /* end of the list */ @@ -220,7 +221,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, if (plist[j].u.f < 10.0) ptr += sprintf(fbuf, " "); - snprintf(ptr, sizeof(fbuf), buf, plist[j].u.f); + snprintf(ptr, sizeof(fbuf), fmt, plist[j].u.f); if (scale_down) ovals[j] = (ovals[j] + 999) / 1000; @@ -230,7 +231,7 @@ static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, if (is_last) break; - if (j % 4 == 3) /* for formatting */ + if ((j % per_line) == per_line - 1) /* for formatting */ log_info("\n"); } -- 2.25.1