aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-05-24 15:52:38 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-06-06 16:04:16 -0400
commit41c8ca2a924b359e8f1768f8550487cd13a1ec03 (patch)
treea8527d035a83e6de91c63d1b49c30ee9dd1bef8b /tools/perf
parent239bd47f8355eb5defc865cf408824b6cfeca5dc (diff)
perf stat: Print topology/time headers with --metric-only
When --metric-only is enabled there were no headers for the topology in interval mode. Also when headers were printed they were on a separate line. Before: $ perf stat --metric-only -A -I 1000 -a 1.001038376 frontend cycles idle insn per cycle stalled cycles per insn branch-misses of all branches 1.001038376 CPU0 123.54% 0.23 5.29 7.61% 1.001038376 CPU1 137.78% 0.24 5.13 10.07% 1.001038376 CPU2 64.48% 0.22 5.50 6.84% After: $ perf stat --metric-only -A -I 1000 -a 1.001111114 CPU0 82.46% 0.32 2.60 7.64% 1.001111114 CPU1 126.63% 0.02 42.83 0.15% 1.001111114 CPU2 193.54% 0.32 2.59 6.92% v2: Move all headers on a single line Reported-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/1464119559-17203-3-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index fd76bb0b18d1..a168e726756b 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1316,7 +1316,7 @@ static int aggr_header_lens[] = {
1316 [AGGR_GLOBAL] = 0, 1316 [AGGR_GLOBAL] = 0,
1317}; 1317};
1318 1318
1319static void print_metric_headers(char *prefix) 1319static void print_metric_headers(const char *prefix, bool no_indent)
1320{ 1320{
1321 struct perf_stat_output_ctx out; 1321 struct perf_stat_output_ctx out;
1322 struct perf_evsel *counter; 1322 struct perf_evsel *counter;
@@ -1327,7 +1327,7 @@ static void print_metric_headers(char *prefix)
1327 if (prefix) 1327 if (prefix)
1328 fprintf(stat_config.output, "%s", prefix); 1328 fprintf(stat_config.output, "%s", prefix);
1329 1329
1330 if (!csv_output) 1330 if (!csv_output && !no_indent)
1331 fprintf(stat_config.output, "%*s", 1331 fprintf(stat_config.output, "%*s",
1332 aggr_header_lens[stat_config.aggr_mode], ""); 1332 aggr_header_lens[stat_config.aggr_mode], "");
1333 1333
@@ -1352,28 +1352,40 @@ static void print_interval(char *prefix, struct timespec *ts)
1352 1352
1353 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep); 1353 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
1354 1354
1355 if (num_print_interval == 0 && !csv_output && !metric_only) { 1355 if (num_print_interval == 0 && !csv_output) {
1356 switch (stat_config.aggr_mode) { 1356 switch (stat_config.aggr_mode) {
1357 case AGGR_SOCKET: 1357 case AGGR_SOCKET:
1358 fprintf(output, "# time socket cpus counts %*s events\n", unit_width, "unit"); 1358 fprintf(output, "# time socket cpus");
1359 if (!metric_only)
1360 fprintf(output, " counts %*s events\n", unit_width, "unit");
1359 break; 1361 break;
1360 case AGGR_CORE: 1362 case AGGR_CORE:
1361 fprintf(output, "# time core cpus counts %*s events\n", unit_width, "unit"); 1363 fprintf(output, "# time core cpus");
1364 if (!metric_only)
1365 fprintf(output, " counts %*s events\n", unit_width, "unit");
1362 break; 1366 break;
1363 case AGGR_NONE: 1367 case AGGR_NONE:
1364 fprintf(output, "# time CPU counts %*s events\n", unit_width, "unit"); 1368 fprintf(output, "# time CPU");
1369 if (!metric_only)
1370 fprintf(output, " counts %*s events\n", unit_width, "unit");
1365 break; 1371 break;
1366 case AGGR_THREAD: 1372 case AGGR_THREAD:
1367 fprintf(output, "# time comm-pid counts %*s events\n", unit_width, "unit"); 1373 fprintf(output, "# time comm-pid");
1374 if (!metric_only)
1375 fprintf(output, " counts %*s events\n", unit_width, "unit");
1368 break; 1376 break;
1369 case AGGR_GLOBAL: 1377 case AGGR_GLOBAL:
1370 default: 1378 default:
1371 fprintf(output, "# time counts %*s events\n", unit_width, "unit"); 1379 fprintf(output, "# time");
1380 if (!metric_only)
1381 fprintf(output, " counts %*s events\n", unit_width, "unit");
1372 case AGGR_UNSET: 1382 case AGGR_UNSET:
1373 break; 1383 break;
1374 } 1384 }
1375 } 1385 }
1376 1386
1387 if (num_print_interval == 0 && metric_only)
1388 print_metric_headers(" ", true);
1377 if (++num_print_interval == 25) 1389 if (++num_print_interval == 25)
1378 num_print_interval = 0; 1390 num_print_interval = 0;
1379} 1391}
@@ -1442,8 +1454,8 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
1442 if (metric_only) { 1454 if (metric_only) {
1443 static int num_print_iv; 1455 static int num_print_iv;
1444 1456
1445 if (num_print_iv == 0) 1457 if (num_print_iv == 0 && !interval)
1446 print_metric_headers(prefix); 1458 print_metric_headers(prefix, false);
1447 if (num_print_iv++ == 25) 1459 if (num_print_iv++ == 25)
1448 num_print_iv = 0; 1460 num_print_iv = 0;
1449 if (stat_config.aggr_mode == AGGR_GLOBAL && prefix) 1461 if (stat_config.aggr_mode == AGGR_GLOBAL && prefix)