From 7dcd9c8d37ddfd628da097e997f26e6a1b657591 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 24 May 2019 15:36:15 -0700 Subject: [PATCH] nvme/perf: adjust column width based on name length Now that we print the addr/nqn for fabrics controllers, adjust the column width in the output so that it prints the full information for fabrics, but keeping a smaller width when it is only PCIE controllers. Signed-off-by: Jim Harris Change-Id: I3532a8928a806b8084047f6686c37cd02d015983 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/456079 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker --- examples/nvme/perf/perf.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 36a61b72e..cc08de548 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -1163,6 +1163,7 @@ print_performance(void) int ns_count; struct worker_thread *worker; struct ns_worker_ctx *ns_ctx; + uint32_t max_strlen; total_io_per_second = 0; total_mb_per_second = 0; @@ -1172,10 +1173,21 @@ print_performance(void) max_latency_so_far = 0; ns_count = 0; + max_strlen = 0; + worker = g_workers; + while (worker) { + ns_ctx = worker->ns_ctx; + while (ns_ctx) { + max_strlen = spdk_max(strlen(ns_ctx->entry->name), max_strlen); + ns_ctx = ns_ctx->next; + } + worker = worker->next; + } + printf("========================================================\n"); - printf("%103s\n", "Latency(us)"); - printf("%-55s: %10s %10s %10s %10s %10s\n", - "Device Information", "IOPS", "MiB/s", "Average", "min", "max"); + printf("%*s\n", max_strlen + 60, "Latency(us)"); + printf("%-*s: %10s %10s %10s %10s %10s\n", + max_strlen + 12, "Device Information", "IOPS", "MiB/s", "Average", "min", "max"); worker = g_workers; while (worker) { @@ -1195,8 +1207,8 @@ print_performance(void) max_latency_so_far = max_latency; } - printf("%-43.43s from core %u: %10.2f %10.2f %10.2f %10.2f %10.2f\n", - ns_ctx->entry->name, worker->lcore, + printf("%-*.*s from core %u: %10.2f %10.2f %10.2f %10.2f %10.2f\n", + max_strlen, max_strlen, ns_ctx->entry->name, worker->lcore, io_per_second, mb_per_second, average_latency, min_latency, max_latency); total_io_per_second += io_per_second; @@ -1213,8 +1225,8 @@ print_performance(void) if (ns_count != 0 && total_io_completed) { sum_ave_latency = ((double)total_io_tsc / total_io_completed) * 1000 * 1000 / g_tsc_rate; printf("========================================================\n"); - printf("%-55s: %10.2f %10.2f %10.2f %10.2f %10.2f\n", - "Total", total_io_per_second, total_mb_per_second, + printf("%-*s: %10.2f %10.2f %10.2f %10.2f %10.2f\n", + max_strlen + 12, "Total", total_io_per_second, total_mb_per_second, sum_ave_latency, min_latency_so_far, max_latency_so_far); printf("\n"); }