From fbb5780216ab3274066d793ab583b15c0efcfcee Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 12 Apr 2025 15:39:42 -0700 Subject: charts: add "'" modifier to Row,Sys,User,Wall columns This helps reading the precise magnitude of these numbers when large. I considered also adding more units for the times, but I kinda like the ability to scan the width of the time columns to see short vs. long durations without actually reading what they contain, as a broad-phase scan. If they were simply HH:MM:SS it'd require scanning the colon-separated columns with enough scrutiny to parse zeroes vs. non-zeroes... --- src/charts.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/charts.c') diff --git a/src/charts.c b/src/charts.c index f5ccab0..1ce8e49 100644 --- a/src/charts.c +++ b/src/charts.c @@ -634,7 +634,7 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t if (heading) str_len = snpf(str, sizeof(str), "Row"); else - str_len = snpf(str, sizeof(str), "%i", row - CHART_NUM_FIXED_HEADER_ROWS); + str_len = snpf(str, sizeof(str), "%'i", row - CHART_NUM_FIXED_HEADER_ROWS); str_justify = VWM_JUSTIFY_LEFT; /* this is kind of hacky, but libvmon doesn't monitor our row, it's implicitly "sampled" when we draw */ @@ -645,7 +645,7 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t if (heading) str_len = snpf(str, sizeof(str), "User"); else - str_len = snpf(str, sizeof(str), "%.2fs", + str_len = snpf(str, sizeof(str), "%'.2fs", (float)proc_stat->utime * charts->inv_ticks_per_sec); str_justify = VWM_JUSTIFY_RIGHT; @@ -655,7 +655,7 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t if (heading) str_len = snpf(str, sizeof(str), "Sys"); else - str_len = snpf(str, sizeof(str), "%.2fs", + str_len = snpf(str, sizeof(str), "%'.2fs", (float)proc_stat->stime * charts->inv_ticks_per_sec); str_justify = VWM_JUSTIFY_RIGHT; @@ -667,7 +667,7 @@ static void draw_columns(vwm_charts_t *charts, vwm_chart_t *chart, vwm_column_t else if (!proc_stat->start || proc_stat->start > sys_stat->boottime) str_len = snpf(str, sizeof(str), "??s"); else - str_len = snpf(str, sizeof(str), "%.2fs", + str_len = snpf(str, sizeof(str), "%'.2fs", (float)(sys_stat->boottime - proc_stat->start) * charts->inv_ticks_per_sec); str_justify = VWM_JUSTIFY_RIGHT; -- cgit v1.2.3