From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751135AbdH1JTc (ORCPT ); Mon, 28 Aug 2017 05:19:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751801AbdH1JT3 (ORCPT ); Mon, 28 Aug 2017 05:19:29 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B50367E422 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Mon, 28 Aug 2017 11:19:26 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH v2 12/19] perf, tools, stat: Factor out generic metric printing Message-ID: <20170828091926.GC4948@krava> References: <20170811232634.30465-1-andi@firstfloor.org> <20170811232634.30465-12-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170811232634.30465-12-andi@firstfloor.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 28 Aug 2017 09:19:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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