lkml.org 
[lkml]   [2017]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 12/19] perf, tools, stat: Factor out generic metric printing
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

\
 
 \ /
  Last update: 2017-08-28 11:20    [W:0.392 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site