2014-04-08 23:46:33

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 10/15 V3] perf, c2c: Display cacheline HITM analysis to stdout

Hi Don,

On Mon, 24 Mar 2014 15:37:01 -0400, Don Zickus wrote:
> + sprintf(summary, "%4d %5.1f%% %5.1f%% %5.1f%% %5.1f%% %8d %8d %8d %8d %18s %6s\n",
> + record,
> + tot_dist * 100.,
> + tot_cumm * 100.,
> + ld_dist * 100.,
> + ld_cumm * 100.,

I think adding a 0 after decimal point helps readability little bit.


> + h->stats.t.rmt_hitm,
> + h->stats.t.lcl_hitm,
> + h->stats.t.st_l1hit,
> + h->stats.t.st_l1miss,
> + addrstr,
> + pidstr);
> +
> + for (j = 0; j < (int)strlen(summary); j++) printf("-");
> + printf("\n");
> + printf("%s", summary);
> + for (j = 0; j < (int)strlen(summary); j++) printf("-");
> + printf("\n");
> +}
> +
> +static void print_socket_stats_str(struct c2c_hit *clo,
> + struct c2c_stats *node_stats)
> +{
> + int i, j;
> +
> + if (!node_stats)
> + return;
> +
> + for (i = 0; i < max_node_num; i++) {
> + struct c2c_stats *stats = &node_stats[i];
> + int num = CPU_COUNT(&stats->cpuset);
> +
> + if (!num) {
> + /* pad align socket info */
> + for (j = 0; j < 21; j++)
> + printf(" ");
> + continue;
> + }
> +
> + printf("%2d{%2d ", i, num);
> +
> + if (clo->stats.t.rmt_hitm > 0)
> + printf("%5.1f%% ", 100. * ((double)stats->t.rmt_hitm / (double) clo->stats.t.rmt_hitm));

Just for your information, most perf tools show 2 digit after decimal
point so it'd be "%5.2f%%" but it's not a strict rule.

Anyway I think multiplying 100.0 first can remove the casts. So code
below will do the same thing..

100.0 * stats->t.rmt_hitm / clo->stats.t.rmt_hitm

The same goes to other percentage calculations too.

Thanks,
Namhyung


> + else
> + printf("%6s ", "n/a");
> +
> + if (clo->stats.t.store > 0)
> + printf("%5.1f%%} ", 100. * ((double)stats->t.store / (double)clo->stats.t.store));
> + else
> + printf("%6s} ", "n/a");
> + }
> +}