* [PATCH] perf stat: Align metric output without events
@ 2025-11-06 7:28 Namhyung Kim
2025-11-11 17:26 ` Ian Rogers
2025-11-12 17:57 ` Namhyung Kim
0 siblings, 2 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-11-06 7:28 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers
Cc: Jiri Olsa, Adrian Hunter, James Clark, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users
One of my concern in the perf stat output was the alignment in the
metrics and shadow stats. I think it missed to calculate the basic
output length using COUNTS_LEN and EVNAME_LEN but missed to add the
unit length like "msec" and surround 2 spaces. I'm not sure why it's
not printed below though.
But anyway, now it shows correctly aligned metric output.
$ perf stat true
Performance counter stats for 'true':
859,772 task-clock # 0.395 CPUs utilized
0 context-switches # 0.000 /sec
0 cpu-migrations # 0.000 /sec
56 page-faults # 65.134 K/sec
1,075,022 instructions # 0.86 insn per cycle
1,255,911 cycles # 1.461 GHz
220,573 branches # 256.548 M/sec
7,381 branch-misses # 3.35% of all branches
TopdownL1 # 19.2 % tma_retiring
# 28.6 % tma_backend_bound
# 9.5 % tma_bad_speculation
# 42.6 % tma_frontend_bound
0.002174871 seconds time elapsed ^
|
0.002154000 seconds user |
0.000000000 seconds sys here
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/stat-display.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index a67b991f4e810336..8fbfec5c0ef7b147 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -439,9 +439,9 @@ static inline void __new_line_std_csv(struct perf_stat_config *config,
aggr_printout(config, os, os->evsel, os->id, os->aggr_nr);
}
-static inline void __new_line_std(struct outstate *os)
+static inline void __new_line_std(struct perf_stat_config *config, struct outstate *os)
{
- fprintf(os->fh, " ");
+ fprintf(os->fh, "%*s", COUNTS_LEN + EVNAME_LEN + config->unit_width + 2, "");
}
static void do_new_line_std(struct perf_stat_config *config,
@@ -450,7 +450,7 @@ static void do_new_line_std(struct perf_stat_config *config,
__new_line_std_csv(config, os);
if (config->aggr_mode == AGGR_NONE)
fprintf(os->fh, " ");
- __new_line_std(os);
+ __new_line_std(config, os);
}
static void print_metric_std(struct perf_stat_config *config,
@@ -583,13 +583,13 @@ static void print_metricgroup_header_std(struct perf_stat_config *config,
int n;
if (!metricgroup_name) {
- __new_line_std(os);
+ __new_line_std(config, os);
return;
}
n = fprintf(config->output, " %*s", EVNAME_LEN, metricgroup_name);
- fprintf(config->output, "%*s", MGROUP_LEN - n - 1, "");
+ fprintf(config->output, "%*s", MGROUP_LEN + config->unit_width + 2 - n, "");
}
/* Filter out some columns that don't work well in metrics only mode */
--
2.51.2.1026.g39e6a42477-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf stat: Align metric output without events
2025-11-06 7:28 [PATCH] perf stat: Align metric output without events Namhyung Kim
@ 2025-11-11 17:26 ` Ian Rogers
2025-11-12 17:57 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-11-11 17:26 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, Jiri Olsa, Adrian Hunter, James Clark,
Peter Zijlstra, Ingo Molnar, LKML, linux-perf-users
On Wed, Nov 5, 2025 at 11:28 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> One of my concern in the perf stat output was the alignment in the
> metrics and shadow stats. I think it missed to calculate the basic
> output length using COUNTS_LEN and EVNAME_LEN but missed to add the
> unit length like "msec" and surround 2 spaces. I'm not sure why it's
> not printed below though.
>
> But anyway, now it shows correctly aligned metric output.
>
> $ perf stat true
>
> Performance counter stats for 'true':
>
> 859,772 task-clock # 0.395 CPUs utilized
> 0 context-switches # 0.000 /sec
> 0 cpu-migrations # 0.000 /sec
> 56 page-faults # 65.134 K/sec
> 1,075,022 instructions # 0.86 insn per cycle
> 1,255,911 cycles # 1.461 GHz
> 220,573 branches # 256.548 M/sec
> 7,381 branch-misses # 3.35% of all branches
> TopdownL1 # 19.2 % tma_retiring
> # 28.6 % tma_backend_bound
> # 9.5 % tma_bad_speculation
> # 42.6 % tma_frontend_bound
>
> 0.002174871 seconds time elapsed ^
> |
> 0.002154000 seconds user |
> 0.000000000 seconds sys here
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf stat: Align metric output without events
2025-11-06 7:28 [PATCH] perf stat: Align metric output without events Namhyung Kim
2025-11-11 17:26 ` Ian Rogers
@ 2025-11-12 17:57 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-11-12 17:57 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo, Ian Rogers
Cc: Jiri Olsa, Adrian Hunter, James Clark, Peter Zijlstra,
Ingo Molnar, LKML, linux-perf-users
On Wed, Nov 05, 2025 at 11:28:34PM -0800, Namhyung Kim wrote:
> One of my concern in the perf stat output was the alignment in the
> metrics and shadow stats. I think it missed to calculate the basic
> output length using COUNTS_LEN and EVNAME_LEN but missed to add the
> unit length like "msec" and surround 2 spaces. I'm not sure why it's
> not printed below though.
>
> But anyway, now it shows correctly aligned metric output.
>
> $ perf stat true
>
> Performance counter stats for 'true':
>
> 859,772 task-clock # 0.395 CPUs utilized
> 0 context-switches # 0.000 /sec
> 0 cpu-migrations # 0.000 /sec
> 56 page-faults # 65.134 K/sec
> 1,075,022 instructions # 0.86 insn per cycle
> 1,255,911 cycles # 1.461 GHz
> 220,573 branches # 256.548 M/sec
> 7,381 branch-misses # 3.35% of all branches
> TopdownL1 # 19.2 % tma_retiring
> # 28.6 % tma_backend_bound
> # 9.5 % tma_bad_speculation
> # 42.6 % tma_frontend_bound
>
> 0.002174871 seconds time elapsed ^
> |
> 0.002154000 seconds user |
> 0.000000000 seconds sys here
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-12 17:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-06 7:28 [PATCH] perf stat: Align metric output without events Namhyung Kim
2025-11-11 17:26 ` Ian Rogers
2025-11-12 17:57 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).