* [PATCH v2 9/9] perf annotate: Use the sample period when calculating the percentage
@ 2017-07-13 17:46 Taeung Song
2017-07-18 16:23 ` Namhyung Kim
0 siblings, 1 reply; 3+ messages in thread
From: Taeung Song @ 2017-07-13 17:46 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, Namhyung Kim, Jiri Olsa
Currently the percentages of perf-annotate are calculated
with number of samples, not the sample period.
So fix it to correspond with perf-report using the sample period
for the calculation.
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 | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index d9bdedf..28a6d11 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -988,7 +988,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
if (h->total_samples) {
sample->nr_samples = hits;
sample->period = p;
- percent = 100.0 * hits / h->total_samples;
+ percent = 100.0 * p / h->total_period;
}
}
@@ -1730,8 +1730,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
start = map__rip_2objdump(map, sym->start);
for (i = 0; i < len; i++) {
- u64 offset, nr_samples;
+ u64 offset;
double percent_max = 0.0;
+ struct sym_hist_entry sample;
src_line->nr_pcnt = nr_pcnt;
@@ -1739,15 +1740,15 @@ 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;
+ sample = h->addr[i];
if (h->total_samples)
- percent = 100.0 * nr_samples / h->total_samples;
+ percent = 100.0 * sample.period / h->total_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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 9/9] perf annotate: Use the sample period when calculating the percentage
2017-07-13 17:46 [PATCH v2 9/9] perf annotate: Use the sample period when calculating the percentage Taeung Song
@ 2017-07-18 16:23 ` Namhyung Kim
2017-07-19 17:34 ` Taeung Song
0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2017-07-18 16:23 UTC (permalink / raw)
To: Taeung Song
Cc: Arnaldo Carvalho de Melo, linux-kernel, Jiri Olsa, kernel-team
On Fri, Jul 14, 2017 at 02:46:20AM +0900, Taeung Song wrote:
> Currently the percentages of perf-annotate are calculated
> with number of samples, not the sample period.
> So fix it to correspond with perf-report using the sample period
> for the calculation.
Not sure someone still wants the old behavior. Maybe it'd be better
to honor --show-nr-samples option.
>
> 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 | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index d9bdedf..28a6d11 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -988,7 +988,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
> if (h->total_samples) {
It seems checking total_period here is clearer and safer. But I guess
it would have same effect 99.9% but still..
> sample->nr_samples = hits;
> sample->period = p;
> - percent = 100.0 * hits / h->total_samples;
> + percent = 100.0 * p / h->total_period;
> }
> }
>
> @@ -1730,8 +1730,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
> start = map__rip_2objdump(map, sym->start);
>
> for (i = 0; i < len; i++) {
> - u64 offset, nr_samples;
> + u64 offset;
> double percent_max = 0.0;
> + struct sym_hist_entry sample;
>
> src_line->nr_pcnt = nr_pcnt;
>
> @@ -1739,15 +1740,15 @@ 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;
> + sample = h->addr[i];
>
> if (h->total_samples)
Ditto.
Thanks,
Namhyung
> - percent = 100.0 * nr_samples / h->total_samples;
> + percent = 100.0 * sample.period / h->total_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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 9/9] perf annotate: Use the sample period when calculating the percentage
2017-07-18 16:23 ` Namhyung Kim
@ 2017-07-19 17:34 ` Taeung Song
0 siblings, 0 replies; 3+ messages in thread
From: Taeung Song @ 2017-07-19 17:34 UTC (permalink / raw)
To: Namhyung Kim
Cc: Arnaldo Carvalho de Melo, linux-kernel, Jiri Olsa, kernel-team
On 07/19/2017 01:23 AM, Namhyung Kim wrote:
> On Fri, Jul 14, 2017 at 02:46:20AM +0900, Taeung Song wrote:
>> Currently the percentages of perf-annotate are calculated
>> with number of samples, not the sample period.
>> So fix it to correspond with perf-report using the sample period
>> for the calculation.
>
> Not sure someone still wants the old behavior. Maybe it'd be better
> to honor --show-nr-samples option.
>
>
You mean that if users use --show-nr-samples option,
we can calculate the percent values with number of samples, right ?
>>
>> 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 | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
>> index d9bdedf..28a6d11 100644
>> --- a/tools/perf/util/annotate.c
>> +++ b/tools/perf/util/annotate.c
>> @@ -988,7 +988,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
>> if (h->total_samples) {
>
> It seems checking total_period here is clearer and safer. But I guess
> it would have same effect 99.9% but still..
>
>
I got it.
>> sample->nr_samples = hits;
>> sample->period = p;
>> - percent = 100.0 * hits / h->total_samples;
>> + percent = 100.0 * p / h->total_period;
>> }
>> }
>>
>> @@ -1730,8 +1730,9 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
>> start = map__rip_2objdump(map, sym->start);
>>
>> for (i = 0; i < len; i++) {
>> - u64 offset, nr_samples;
>> + u64 offset;
>> double percent_max = 0.0;
>> + struct sym_hist_entry sample;
>>
>> src_line->nr_pcnt = nr_pcnt;
>>
>> @@ -1739,15 +1740,15 @@ 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;
>> + sample = h->addr[i];
>>
>> if (h->total_samples)
>
> Ditto.
>
> Thanks,
> Namhyung
>
>
ok
Thanks,
Taeung
>> - percent = 100.0 * nr_samples / h->total_samples;
>> + percent = 100.0 * sample.period / h->total_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
>>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-19 17:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 17:46 [PATCH v2 9/9] perf annotate: Use the sample period when calculating the percentage Taeung Song
2017-07-18 16:23 ` Namhyung Kim
2017-07-19 17:34 ` Taeung Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome