Skip to content

Commit cc68628

Browse files
Ashay Raneacmel
authored andcommitted
perf report: Correct display of samples and events in header
This patch prints the number of samples and the count of performance events separately. This allows comparing performance of different applications with each other. Previously, the sample count was displayed against an 'Events:' heading. With this patch, the header now reads (for example): Samples: 5K of event 'instructions' Event count (approx.): 2993026545 The patch covers both the stdio and the browser interface. Signed-off-by: Ashay Rane <[email protected]> [ committer note: Fixed wrt e7f01d1 ] Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 08be4ee commit cc68628

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

tools/perf/builtin-report.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,15 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
296296
{
297297
size_t ret;
298298
char unit;
299-
unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
299+
unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
300+
u64 nr_events = self->stats.total_period;
300301

301-
nr_events = convert_unit(nr_events, &unit);
302-
ret = fprintf(fp, "# Events: %lu%c", nr_events, unit);
302+
nr_samples = convert_unit(nr_samples, &unit);
303+
ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
303304
if (evname != NULL)
304-
ret += fprintf(fp, " %s", evname);
305+
ret += fprintf(fp, " of event '%s'", evname);
306+
307+
ret += fprintf(fp, "\n# Event count (approx.): %lu", nr_events);
305308
return ret + fprintf(fp, "\n#\n");
306309
}
307310

tools/perf/util/ui/browsers/hists.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,14 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
840840
int printed;
841841
const struct dso *dso = self->dso_filter;
842842
const struct thread *thread = self->thread_filter;
843-
unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
843+
unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
844+
u64 nr_events = self->stats.total_period;
845+
846+
nr_samples = convert_unit(nr_samples, &unit);
847+
printed = scnprintf(bf, size,
848+
"Samples: %lu%c of event '%s', Event count (approx.): %lu",
849+
nr_samples, unit, ev_name, nr_events);
844850

845-
nr_events = convert_unit(nr_events, &unit);
846-
printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
847851

848852
if (self->uid_filter_str)
849853
printed += snprintf(bf + printed, size - printed,

0 commit comments

Comments
 (0)