Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1721394

Re: [PATCH v2 12/19] perf, tools, stat: Factor out generic metric printing

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 12/19] perf, tools, stat: Factor out generic metric printing
Date 2017-08-28 11:20 +0200
Message-ID <ujon7-3MV-15@gated-at.bofh.it> (permalink)
References <udrxo-1lO-5@gated-at.bofh.it> <udrxo-1lO-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Aug 11, 2017 at 04:26:27PM -0700, Andi Kleen wrote:

SNIP

> +static void generic_metric(const char *metric_expr,
> +			   struct perf_evsel **metric_events,
> +			   char *name,
> +			   const char *metric_name,
> +			   double avg,
> +			   int cpu,
> +			   int ctx,
> +			   struct perf_stat_output_ctx *out)
> +{
> +	print_metric_t print_metric = out->print_metric;
> +	struct parse_ctx pctx;
> +	double ratio;
> +	int i;
> +	void *ctxp = out->ctx;
> +
> +	expr__ctx_init(&pctx);
> +	expr__add_id(&pctx, name, avg);
> +	for (i = 0; metric_events[i]; i++) {
> +		struct saved_value *v;
> +
> +		v = saved_value_lookup(metric_events[i], cpu, ctx, false);
> +		if (!v)
> +			break;
> +		expr__add_id(&pctx, metric_events[i]->name, avg_stats(&v->stats));
> +	}
> +	if (!metric_events[i]) {
> +		const char *p = metric_expr;
> +
> +		if (expr__parse(&ratio, &pctx, &p) == 0)
> +			print_metric(ctxp, NULL, "%8.1f",
> +				metric_name ?
> +				metric_name :
> +			out->force_header ?  name : "",

nit, missing tab ^^^

jirka

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH v2 12/19] perf, tools, stat: Factor out generic metric  printing Jiri Olsa <jolsa@redhat.com> - 2017-08-28 11:20 +0200

csiph-web