Skip to content

Commit

Permalink
perf report: Show event sample counts in --stat output
Browse files Browse the repository at this point in the history
To make the output identical with perf report -D, it needs to show
per-event sample counts along with the aggregated stat  at the end.

Reviewed-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210427013717.1651674-4-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Apr 29, 2021
1 parent 0f0abba commit 55f7544
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,22 @@ static void report__output_resort(struct report *rep)
ui_progress__finish();
}

static int count_sample_event(struct perf_tool *tool __maybe_unused,
union perf_event *event __maybe_unused,
struct perf_sample *sample __maybe_unused,
struct evsel *evsel,
struct machine *machine __maybe_unused)
{
struct hists *hists = evsel__hists(evsel);

hists__inc_nr_events(hists);
return 0;
}

static void stats_setup(struct report *rep)
{
memset(&rep->tool, 0, sizeof(rep->tool));
rep->tool.sample = count_sample_event;
rep->tool.no_warn = true;
}

Expand All @@ -719,6 +732,7 @@ static int stats_print(struct report *rep)
struct perf_session *session = rep->session;

perf_session__fprintf_nr_events(session, stdout);
perf_evlist__fprintf_nr_events(session->evlist, stdout);
return 0;
}

Expand Down

0 comments on commit 55f7544

Please sign in to comment.