On Tue, Apr 22, 2014 at 05:49:43PM +0900, Namhyung Kim wrote:
> Those stats are counted counted in multiple places so that they can
> confuse readers of the code.  This is a preparation of later change
> and do not intend any functional difference.
> 
> Signed-off-by: Namhyung Kim <namhy...@kernel.org>
> ---
>  tools/perf/builtin-report.c | 37 ++++++++++++++++++++++---------------
>  1 file changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 76e2bb6cf571..375fc504386e 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -57,6 +57,8 @@ struct report {
>       const char              *cpu_list;
>       const char              *symbol_filter_str;
>       float                   min_percent;
> +     u64                     nr_entries;
> +     u64                     nr_samples;
>       DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
>  };
>  
> @@ -121,6 +123,12 @@ static int report__add_mem_hist_entry(struct report 
> *rep, struct addr_location *
>                       goto out;
>       }
>  
> +     rep->nr_samples++;
> +     if (he->stat.nr_events == 1) {
> +             /* count new entries only */
> +             rep->nr_entries++;
> +     }
> +
>       evsel->hists.stats.total_period += cost;
>       hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
>       if (!he->filtered)
> @@ -176,6 +184,12 @@ static int report__add_branch_hist_entry(struct report 
> *rep, struct addr_locatio
>                                       goto out;
>                       }
>  
> +                     rep->nr_samples++;
> +                     if (he->stat.nr_events == 1) {
> +                             /* count new entries only */
> +                             rep->nr_entries++;
> +                     }
> +
>                       evsel->hists.stats.total_period += 1;
>                       hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
>                       if (!he->filtered)
> @@ -212,6 +226,12 @@ static int report__add_hist_entry(struct report *rep, 
> struct perf_evsel *evsel,
>       if (ui__has_annotation())
>               err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
>  
> +     rep->nr_samples++;
> +     if (he->stat.nr_events == 1) {
> +             /* count new entries only */
> +             rep->nr_entries++;
> +     }

smeels like we could use function for this ^^^

also it took me a while to figure out the reason for the condition,
maybe there could be more comment about that

thanks,
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to