diff options
author | Taeung Song <treeze.taeung@gmail.com> | 2017-08-18 04:46:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-08-18 09:31:53 -0400 |
commit | 1ac39372e06f5009982aaaf890fc5bbd044bb047 (patch) | |
tree | 38059befa819af8d01667ef4733a41f117ab91ca | |
parent | 9a57eaf1d2443d34cce0562f425228c37a8ec019 (diff) |
perf annotate stdio: Support --show-nr-samples option
Add --show-nr-samples option to "perf annotate" so that it matches "perf
report".
Committer note:
Note that it can't be used together with --show-total-period, which
seems like a silly limitation, that can be lifted at some point.
Made it bail out if not on --stdio.
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1503046008-5511-1-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/Documentation/perf-annotate.txt | 4 | ||||
-rw-r--r-- | tools/perf/builtin-annotate.c | 16 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 6 |
3 files changed, 23 insertions, 3 deletions
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index a89273d8e744..2a5975c91cbd 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt | |||
@@ -43,6 +43,10 @@ OPTIONS | |||
43 | --quiet:: | 43 | --quiet:: |
44 | Do not show any message. (Suppress -v) | 44 | Do not show any message. (Suppress -v) |
45 | 45 | ||
46 | -n:: | ||
47 | --show-nr-samples:: | ||
48 | Show the number of samples for each symbol | ||
49 | |||
46 | -D:: | 50 | -D:: |
47 | --dump-raw-trace:: | 51 | --dump-raw-trace:: |
48 | Dump raw trace in ASCII. | 52 | Dump raw trace in ASCII. |
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 658c920d74b9..89fc0389dc76 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -403,7 +403,7 @@ int cmd_annotate(int argc, const char **argv) | |||
403 | struct perf_data_file file = { | 403 | struct perf_data_file file = { |
404 | .mode = PERF_DATA_MODE_READ, | 404 | .mode = PERF_DATA_MODE_READ, |
405 | }; | 405 | }; |
406 | const struct option options[] = { | 406 | struct option options[] = { |
407 | OPT_STRING('i', "input", &input_name, "file", | 407 | OPT_STRING('i', "input", &input_name, "file", |
408 | "input file name"), | 408 | "input file name"), |
409 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", | 409 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
@@ -445,13 +445,20 @@ int cmd_annotate(int argc, const char **argv) | |||
445 | "Show event group information together"), | 445 | "Show event group information together"), |
446 | OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, | 446 | OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, |
447 | "Show a column with the sum of periods"), | 447 | "Show a column with the sum of periods"), |
448 | OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, | ||
449 | "Show a column with the number of samples"), | ||
448 | OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", | 450 | OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", |
449 | "'always' (default), 'never' or 'auto' only applicable to --stdio mode", | 451 | "'always' (default), 'never' or 'auto' only applicable to --stdio mode", |
450 | stdio__config_color, "always"), | 452 | stdio__config_color, "always"), |
451 | OPT_END() | 453 | OPT_END() |
452 | }; | 454 | }; |
453 | int ret = hists__init(); | 455 | int ret; |
456 | |||
457 | set_option_flag(options, 0, "show-total-period", PARSE_OPT_EXCLUSIVE); | ||
458 | set_option_flag(options, 0, "show-nr-samples", PARSE_OPT_EXCLUSIVE); | ||
459 | |||
454 | 460 | ||
461 | ret = hists__init(); | ||
455 | if (ret < 0) | 462 | if (ret < 0) |
456 | return ret; | 463 | return ret; |
457 | 464 | ||
@@ -467,6 +474,11 @@ int cmd_annotate(int argc, const char **argv) | |||
467 | annotate.sym_hist_filter = argv[0]; | 474 | annotate.sym_hist_filter = argv[0]; |
468 | } | 475 | } |
469 | 476 | ||
477 | if (symbol_conf.show_nr_samples && !annotate.use_stdio) { | ||
478 | pr_err("--show-nr-samples is only available in --stdio mode at this time\n"); | ||
479 | return ret; | ||
480 | } | ||
481 | |||
470 | if (quiet) | 482 | if (quiet) |
471 | perf_quiet_option(); | 483 | perf_quiet_option(); |
472 | 484 | ||
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 2dab0e5a7f2f..4397a8b6e6cd 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -1145,6 +1145,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st | |||
1145 | if (symbol_conf.show_total_period) | 1145 | if (symbol_conf.show_total_period) |
1146 | color_fprintf(stdout, color, " %11" PRIu64, | 1146 | color_fprintf(stdout, color, " %11" PRIu64, |
1147 | sample.period); | 1147 | sample.period); |
1148 | else if (symbol_conf.show_nr_samples) | ||
1149 | color_fprintf(stdout, color, " %7" PRIu64, | ||
1150 | sample.nr_samples); | ||
1148 | else | 1151 | else |
1149 | color_fprintf(stdout, color, " %7.2f", percent); | 1152 | color_fprintf(stdout, color, " %7.2f", percent); |
1150 | } | 1153 | } |
@@ -1825,7 +1828,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, | |||
1825 | width *= evsel->nr_members; | 1828 | width *= evsel->nr_members; |
1826 | 1829 | ||
1827 | graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n", | 1830 | graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n", |
1828 | width, width, symbol_conf.show_total_period ? "Event count" : "Percent", | 1831 | width, width, symbol_conf.show_total_period ? "Period" : |
1832 | symbol_conf.show_nr_samples ? "Samples" : "Percent", | ||
1829 | d_filename, evsel_name, h->nr_samples); | 1833 | d_filename, evsel_name, h->nr_samples); |
1830 | 1834 | ||
1831 | printf("%-*.*s----\n", | 1835 | printf("%-*.*s----\n", |