Re: [PATCH] perf stat: Add --hide-zero-events option to suppress zero-count events

From: Aaron Tomlin

Date: Fri Jul 17 2026 - 20:49:29 EST


On Thu, Jul 16, 2026 at 10:22:01PM -0700, Ian Rogers wrote:
> I think this makes sense but perhaps the Python interface makes more
> sense for what you're doing. For example, the ilist app shows all
> events and metrics:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/python/ilist.py?h=perf-tools-next
>
> Perhaps we could also add some tests for better coverage:
> https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/shell/stat.sh?h=perf-tools-next
>
> Other than that:
> Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> Thanks,

Hi Ian,

Thanks for the feedback and the "Reviewed-by:" tag!

Regarding the Python interface, it's definitely a powerful tool for custom
scripting and listing events. However, I prefer using 'perf stat' directly
on the command line for a few reasons:

1. Standard 'perf stat' works out-of-the-box on minimal production
systems where Python and the perf python bindings/dependencies
might not be installed or packaged

2. Having a simple command-line flag like '--hide-zero-events' makes
quick, interactive profiling directly on the CLI much more
convenient

I have updated the patch to incorporate your suggestion and added shell
test coverage for both '--hide-zero-events' and '--metric-only' in
tools/perf/tests/shell/stat.sh. I will submit v2 shortly.

Kind regards,
--
Aaron Tomlin