git: 105c7c4b8dce - main - iostat: Tune formatting for higher disk speeds

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 10 Nov 2023 23:40:54 UTC
The branch main has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=105c7c4b8dcec22567a5f137b9406a95fbd9f4f2

commit 105c7c4b8dcec22567a5f137b9406a95fbd9f4f2
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2023-11-10 23:35:38 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2023-11-10 23:35:38 +0000

    iostat: Tune formatting for higher disk speeds
    
    MFC after:      2 weeks
---
 usr.sbin/iostat/iostat.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index d4f7a2519a1b..c6ba6aa8a7a2 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -765,9 +765,9 @@ phdr(void)
 					(void)printf(" blk xfr msps ");
 			} else {
 				if (Iflag == 0)
-					printf(" KB/t  tps  MB/s ");
+					printf("KB/t   tps  MB/s ");
 				else
-					printf(" KB/t xfrs    MB ");
+					printf("KB/t  xfrs    MB ");
 			}
 			printed++;
 		}
@@ -934,26 +934,30 @@ devstats(int perf_select, long double etime, int havelast)
 				       msdig,
 				       ms_per_transaction);
 			else
-				printf("%4.1" PRIu64 "%4.1" PRIu64 "%5.*Lf ",
+				printf("%4" PRIu64 "%4" PRIu64 "%5.*Lf ",
 				       total_blocks,
 				       total_transfers,
 				       msdig,
 				       ms_per_transaction);
 		} else {
 			if (Iflag == 0)
-				printf(" %4.*Lf %4.0Lf %5.*Lf ",
+				printf("%4.*Lf %5.0Lf %5.*Lf ",
 				       kb_per_transfer >= 100 ? 0 : 1,
 				       kb_per_transfer,
 				       transfers_per_second,
-				       mb_per_second >= 1000 ? 0 : 1,
+				       mb_per_second >= 1000 ? 0 :
+					(total_mb >= 100 ? 1 : 2),
 				       mb_per_second);
 			else {
 				total_mb = total_bytes;
 				total_mb /= 1024 * 1024;
 
-				printf(" %4.1Lf %4.1" PRIu64 " %5.2Lf ",
+				printf("%4.*Lf %5" PRIu64 " %5.*Lf ",
+				       kb_per_transfer >= 100 ? 0 : 1,
 				       kb_per_transfer,
 				       total_transfers,
+				       total_mb >= 1000 ? 0 :
+					(total_mb >= 100 ? 1 : 2),
 				       total_mb);
 			}
 		}