Skip to contentSkip to conversation

perf report: Correct display of samples and events in header

PATCH In review Ashay Rane 2 participants 2 messages Mar 21, 2012 perf events

lore
Share & tools
lore

Ashay Rane

author
#0 lore raw

PATCH 1/1 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.

---
 tools/perf/builtin-report.c         |   11 +++++++----
 tools/perf/util/ui/browsers/hists.c |    9 ++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)
tools/perf/builtin-report.c +7 -4
index 8e91c6e..2ee7783 100644
@@ -295,12 +295,15 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
 {
 	size_t ret;
 	char unit;
-	unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	u64 nr_events = self->stats.total_period;
 
-	nr_events = convert_unit(nr_events, &unit);
-	ret = fprintf(fp, "# Events: %lu%c", nr_events, unit);
+	nr_samples = convert_unit(nr_samples, &unit);
+	ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
 	if (evname != NULL)
-		ret += fprintf(fp, " %s", evname);
+		ret += fprintf(fp, " of event '%s'", evname);
+
+	ret += fprintf(fp, "\n# Event count (approx.): %lu", nr_events);
 	return ret + fprintf(fp, "\n#\n");
 }
 
tools/perf/util/ui/browsers/hists.c +6 -3
index fa530fc..d9ec415 100644
@@ -837,10 +837,13 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
 	int printed;
 	const struct dso *dso = self->dso_filter;
 	const struct thread *thread = self->thread_filter;
-	unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	u64 nr_events = self->stats.total_period;
 
-	nr_events = convert_unit(nr_events, &unit);
-	printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
+	nr_samples = convert_unit(nr_samples, &unit);
+	printed = scnprintf(bf, size,
+			    "Samples: %lu%c of event '%s', Event count (approx.): %lu",
+			    nr_samples, unit, ev_name, nr_events);
 
 	if (self->uid_filter_str)
 		printed += snprintf(bf + printed, size - printed,
Signature · 1 line
1.7.9.3
#1 lore raw

Em Tue, Mar 20, 2012 at 08:20:28PM -0500, Ashay Rane escreveu:

Quoted 8 lines

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.

Patches that are not bug fixes should be done on tip/perf/core, please do that and resubmit.

git remote add tip git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
git remote update tip
git checkout -b perf/core tip/perf/core

:-)

- Arnaldo

---

Quoted 51 lines
 tools/perf/builtin-report.c         |   11 +++++++----
 tools/perf/util/ui/browsers/hists.c |    9 ++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)
tools/perf/builtin-report.c +7 -4
index 8e91c6e..2ee7783 100644
@@ -295,12 +295,15 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
 {
 	size_t ret;
 	char unit;
-	unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	u64 nr_events = self->stats.total_period;
 
-	nr_events = convert_unit(nr_events, &unit);
-	ret = fprintf(fp, "# Events: %lu%c", nr_events, unit);
+	nr_samples = convert_unit(nr_samples, &unit);
+	ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
 	if (evname != NULL)
-		ret += fprintf(fp, " %s", evname);
+		ret += fprintf(fp, " of event '%s'", evname);
+
+	ret += fprintf(fp, "\n# Event count (approx.): %lu", nr_events);
 	return ret + fprintf(fp, "\n#\n");
 }
 
tools/perf/util/ui/browsers/hists.c +6 -3
index fa530fc..d9ec415 100644
@@ -837,10 +837,13 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
 	int printed;
 	const struct dso *dso = self->dso_filter;
 	const struct thread *thread = self->thread_filter;
-	unsigned long nr_events = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE];
+	u64 nr_events = self->stats.total_period;
 
-	nr_events = convert_unit(nr_events, &unit);
-	printed = scnprintf(bf, size, "Events: %lu%c %s", nr_events, unit, ev_name);
+	nr_samples = convert_unit(nr_samples, &unit);
+	printed = scnprintf(bf, size,
+			    "Samples: %lu%c of event '%s', Event count (approx.): %lu",
+			    nr_samples, unit, ev_name, nr_events);
 
 	if (self->uid_filter_str)
 		printed += snprintf(bf + printed, size - printed,
Signature · 1 line
1.7.9.3