[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c26d35d6-cfa9-3735-363c-05e5be981082@linux.intel.com>
Date: Wed, 19 Apr 2017 08:33:56 +0800
From: "Jin, Yao" <yao.jin@...ux.intel.com>
To: Jiri Olsa <jolsa@...hat.com>
Cc: acme@...nel.org, jolsa@...nel.org, peterz@...radead.org,
mingo@...hat.com, alexander.shishkin@...ux.intel.com,
Linux-kernel@...r.kernel.org, ak@...ux.intel.com,
kan.liang@...el.com, yao.jin@...el.com,
linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v4 5/5] perf report: Show branch type in callchain entry
On 4/19/2017 2:53 AM, Jiri Olsa wrote:
> On Wed, Apr 12, 2017 at 06:21:06AM +0800, Jin Yao wrote:
>
> SNIP
>
>> +static int branch_type_str(struct branch_type_stat *stat,
>> + char *bf, int bfsize)
>> +{
>> + int i, j = 0, printed = 0;
>> + u64 total = 0;
>> +
>> + for (i = 0; i < PERF_BR_MAX; i++)
>> + total += stat->counts[i];
>> +
>> + if (total == 0)
>> + return 0;
>> +
>> + printed += scnprintf(bf + printed, bfsize - printed, " (");
>> +
>> + if (stat->jcc_fwd > 0) {
>> + j++;
>> + printed += scnprintf(bf + printed, bfsize - printed,
>> + "JCC forward");
>> + }
>> +
>> + if (stat->jcc_bwd > 0) {
>> + if (j++)
>> + printed += scnprintf(bf + printed, bfsize - printed,
>> + " JCC backward");
>> + else
>> + printed += scnprintf(bf + printed, bfsize - printed,
>> + "JCC backward");
>> + }
>> +
>> + if (stat->cross_4k > 0) {
>> + if (j++)
>> + printed += scnprintf(bf + printed, bfsize - printed,
>> + " CROSS_4K");
>> + else
>> + printed += scnprintf(bf + printed, bfsize - printed,
>> + "CROSS_4K");
>> + }
> could that 2 legs if be shortened to just one scnprintf like (untested):
>
> printed += scnprintf(bf + printed, bfsize - printed, "%s%s", j++ ? " " : "", "CROSS_4K");
>
> I'd also probably use some kind of macro or function
> with all that similar code, but I dont insist ;-)
>
> thanks,
> jirka
Thanks for this suggestion. I will use this kind of code. Of course, I
will test. :)
Thanks
Jin Yao
Powered by blists - more mailing lists