Re: [PATCH v2 2/2] perf stat: Report summary for interval mode
From: Jiri Olsa
Date: Mon May 04 2020 - 19:42:11 EST
On Sat, May 02, 2020 at 10:07:05AM +0800, Jin Yao wrote:
SNIP
> init_stats(&walltime_nsecs_stats);
> update_stats(&walltime_nsecs_stats, stat_config.interval * 1000000);
> print_counters(&rs, 0, NULL);
> + walltime_nsecs_stats = walltime_nsecs_stats_bak;
> }
>
> static void enable_counters(void)
> @@ -732,7 +735,14 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
> * avoid arbitrary skew, we must read all counters before closing any
> * group leaders.
> */
> - read_counters(&(struct timespec) { .tv_nsec = t1-t0 });
> + if (!interval)
> + read_counters(&(struct timespec) { .tv_nsec = t1-t0 });
> + else {
> + stat_config.interval = 0;
> + stat_config.summary = true;
> + perf_evlist__copy_summary_counts(evsel_list);
> + perf_evlist__process_summary_counts(&stat_config, evsel_list);
I think keeping the summary and copying it to evsel->count is ok,
but when we pretend to have new counts in place, could we process
it with perf_stat_process_counter function? so we keep just
1 processing code?
perhaps have some setup functions for non-interval settings?
SNIP
> +
> + evsel->prev_raw_counts->aggr = evsel->summary_counts->aggr;
> +}
> +
> +void perf_evlist__copy_summary_counts(struct evlist *evlist)
> +{
> + struct evsel *evsel;
> +
> + evlist__for_each_entry(evlist, evsel)
> + perf_evsel__copy_summary_counts(evsel);
> +}
> +
> +static void perf_stat_process_summary_counts(struct perf_stat_config *config,
> + struct evsel *evsel)
> +{
> + struct perf_counts_values *summary = &evsel->summary_counts->aggr;
as I said earlier, why not copy all summary_counts data into 'counts'
and use the current code the process and display the result?
thanks,
jirka
> + struct perf_stat_evsel *ps = evsel->stats;
> + u64 *count = evsel->summary_counts->aggr.values;
> + int i;
> +
> + if (!config->summary || config->aggr_mode != AGGR_GLOBAL)
> + return;
> +
> + for (i = 0; i < 3; i++)
> + init_stats(&ps->res_stats[i]);
> +
> + perf_counts_values__scale(summary, config->scale,
> + &evsel->summary_counts->scaled);
> +
> + for (i = 0; i < 3; i++)
SNIP