From: Jens Axboe Date: Mon, 6 Nov 2006 13:03:03 +0000 (+0100) Subject: [PATCH] Print pretty bs values X-Git-Tag: fio-1.8~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f8977ee606bc51138a77f6a1b653df00faa77742;hp=787f7e95a3fb3bbe88431da53337bb9551d2357c [PATCH] Print pretty bs values Convert 1024 to 1K and so on. Signed-off-by: Jens Axboe --- diff --git a/init.c b/init.c index a8ff5ac0..37cf0508 100644 --- a/init.c +++ b/init.c @@ -511,6 +511,27 @@ static void fixup_options(struct thread_data *td) log_err("fio: bs_unaligned may not work with raw io\n"); } +/* + * This function leaks the buffer + */ +static char *to_kmg(unsigned int val) +{ + char *buf = malloc(32); + char post[] = { 0, 'K', 'G', 'P', -1 }; + char *p = post; + + while (*p != -1) { + if (val & 1023) + break; + + val >>= 10; + p++; + } + + snprintf(buf, 31, "%u%c", val, *p); + return buf; +} + /* * Adds a job to the list of things todo. Sanitizes the various options * to make sure we don't have conflicts, and initializes various @@ -624,8 +645,21 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (!job_add_num) { if (td->io_ops->flags & FIO_CPUIO) fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle); - else - fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d/%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs[DDIR_READ], td->max_bs[DDIR_READ], td->min_bs[DDIR_WRITE], td->max_bs[DDIR_WRITE], td->rate, td->io_ops->name, td->iodepth); + else { + char *c1, *c2, *c3, *c4; + + c1 = to_kmg(td->min_bs[DDIR_READ]); + c2 = to_kmg(td->max_bs[DDIR_READ]); + c3 = to_kmg(td->min_bs[DDIR_WRITE]); + c4 = to_kmg(td->max_bs[DDIR_WRITE]); + + fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%s-%s/%s-%s, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth); + + free(c1); + free(c2); + free(c3); + free(c4); + } } else if (job_add_num == 1) fprintf(f_out, "...\n"); }