From: Taeung Song <treeze.taeung@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH v4 9/9] perf annotate: Calculate the percentage with period or number of samples
Date: Fri, 28 Jul 2017 01:16:43 +0900 [thread overview]
Message-ID: <1501172203-6987-1-git-send-email-treeze.taeung@gmail.com> (raw)
To correspond with perf-report using the sample period
for the percentage calculation, calculate the percentage with period.
But if --show-nr-samples was used,
figure out the percentage by number of samples.
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
tools/perf/util/annotate.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 522b67b..cb0080b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -968,9 +968,13 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
}
if (h->period) {
- sample->period = period;
sample->nr_samples = hits;
- percent = 100.0 * hits / h->nr_samples;
+ sample->period = period;
+
+ if (symbol_conf.show_nr_samples)
+ percent = 100.0 * hits / h->nr_samples;
+ else
+ percent = 100.0 * period / h->period;
}
}
@@ -1710,6 +1714,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
for (i = 0; i < len; i++) {
u64 offset;
double percent_max = 0.0;
+ struct sym_hist_entry sample;
src_line->nr_pcnt = nr_pcnt;
@@ -1717,14 +1722,18 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
double percent = 0.0;
h = annotation__histogram(notes, evidx + k);
- nr_samples = h->addr[i].nr_samples;
- if (h->period)
- percent = 100.0 * nr_samples / h->nr_samples;
+ sample = h->addr[i];
+ if (h->period) {
+ if (symbol_conf.show_nr_samples)
+ percent = 100.0 * sample.nr_samples / h->nr_samples;
+ else
+ percent = 100.0 * sample.period / h->period;
+ }
if (percent > percent_max)
percent_max = percent;
src_line->samples[k].percent = percent;
- src_line->samples[k].nr = nr_samples;
+ src_line->samples[k].nr = sample.nr_samples;
}
if (percent_max <= 0.5)
--
2.7.4
reply other threads:[~2017-07-27 16:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1501172203-6987-1-git-send-email-treeze.taeung@gmail.com \
--to=treeze.taeung@gmail.com \
--cc=acme@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®