diff options
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a9f06715e44..5deb17d9e79 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -61,6 +61,8 @@ | |||
61 | #include <locale.h> | 61 | #include <locale.h> |
62 | 62 | ||
63 | #define DEFAULT_SEPARATOR " " | 63 | #define DEFAULT_SEPARATOR " " |
64 | #define CNTR_NOT_SUPPORTED "<not supported>" | ||
65 | #define CNTR_NOT_COUNTED "<not counted>" | ||
64 | 66 | ||
65 | static struct perf_event_attr default_attrs[] = { | 67 | static struct perf_event_attr default_attrs[] = { |
66 | 68 | ||
@@ -191,6 +193,7 @@ static int big_num_opt = -1; | |||
191 | static const char *cpu_list; | 193 | static const char *cpu_list; |
192 | static const char *csv_sep = NULL; | 194 | static const char *csv_sep = NULL; |
193 | static bool csv_output = false; | 195 | static bool csv_output = false; |
196 | static bool group = false; | ||
194 | 197 | ||
195 | static volatile int done = 0; | 198 | static volatile int done = 0; |
196 | 199 | ||
@@ -278,14 +281,14 @@ static int create_perf_stat_counter(struct perf_evsel *evsel) | |||
278 | attr->inherit = !no_inherit; | 281 | attr->inherit = !no_inherit; |
279 | 282 | ||
280 | if (system_wide) | 283 | if (system_wide) |
281 | return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, false); | 284 | return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, group); |
282 | 285 | ||
283 | if (target_pid == -1 && target_tid == -1) { | 286 | if (target_pid == -1 && target_tid == -1) { |
284 | attr->disabled = 1; | 287 | attr->disabled = 1; |
285 | attr->enable_on_exec = 1; | 288 | attr->enable_on_exec = 1; |
286 | } | 289 | } |
287 | 290 | ||
288 | return perf_evsel__open_per_thread(evsel, evsel_list->threads, false); | 291 | return perf_evsel__open_per_thread(evsel, evsel_list->threads, group); |
289 | } | 292 | } |
290 | 293 | ||
291 | /* | 294 | /* |
@@ -448,6 +451,7 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
448 | if (verbose) | 451 | if (verbose) |
449 | ui__warning("%s event is not supported by the kernel.\n", | 452 | ui__warning("%s event is not supported by the kernel.\n", |
450 | event_name(counter)); | 453 | event_name(counter)); |
454 | counter->supported = false; | ||
451 | continue; | 455 | continue; |
452 | } | 456 | } |
453 | 457 | ||
@@ -466,6 +470,7 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
466 | die("Not all events could be opened.\n"); | 470 | die("Not all events could be opened.\n"); |
467 | return -1; | 471 | return -1; |
468 | } | 472 | } |
473 | counter->supported = true; | ||
469 | } | 474 | } |
470 | 475 | ||
471 | if (perf_evlist__set_filters(evsel_list)) { | 476 | if (perf_evlist__set_filters(evsel_list)) { |
@@ -513,7 +518,10 @@ static void print_noise_pct(double total, double avg) | |||
513 | if (avg) | 518 | if (avg) |
514 | pct = 100.0*total/avg; | 519 | pct = 100.0*total/avg; |
515 | 520 | ||
516 | fprintf(stderr, " ( +-%6.2f%% )", pct); | 521 | if (csv_output) |
522 | fprintf(stderr, "%s%.2f%%", csv_sep, pct); | ||
523 | else | ||
524 | fprintf(stderr, " ( +-%6.2f%% )", pct); | ||
517 | } | 525 | } |
518 | 526 | ||
519 | static void print_noise(struct perf_evsel *evsel, double avg) | 527 | static void print_noise(struct perf_evsel *evsel, double avg) |
@@ -861,7 +869,7 @@ static void print_counter_aggr(struct perf_evsel *counter) | |||
861 | if (scaled == -1) { | 869 | if (scaled == -1) { |
862 | fprintf(stderr, "%*s%s%*s", | 870 | fprintf(stderr, "%*s%s%*s", |
863 | csv_output ? 0 : 18, | 871 | csv_output ? 0 : 18, |
864 | "<not counted>", | 872 | counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED, |
865 | csv_sep, | 873 | csv_sep, |
866 | csv_output ? 0 : -24, | 874 | csv_output ? 0 : -24, |
867 | event_name(counter)); | 875 | event_name(counter)); |
@@ -878,13 +886,13 @@ static void print_counter_aggr(struct perf_evsel *counter) | |||
878 | else | 886 | else |
879 | abs_printout(-1, counter, avg); | 887 | abs_printout(-1, counter, avg); |
880 | 888 | ||
889 | print_noise(counter, avg); | ||
890 | |||
881 | if (csv_output) { | 891 | if (csv_output) { |
882 | fputc('\n', stderr); | 892 | fputc('\n', stderr); |
883 | return; | 893 | return; |
884 | } | 894 | } |
885 | 895 | ||
886 | print_noise(counter, avg); | ||
887 | |||
888 | if (scaled) { | 896 | if (scaled) { |
889 | double avg_enabled, avg_running; | 897 | double avg_enabled, avg_running; |
890 | 898 | ||
@@ -914,7 +922,8 @@ static void print_counter(struct perf_evsel *counter) | |||
914 | csv_output ? 0 : -4, | 922 | csv_output ? 0 : -4, |
915 | evsel_list->cpus->map[cpu], csv_sep, | 923 | evsel_list->cpus->map[cpu], csv_sep, |
916 | csv_output ? 0 : 18, | 924 | csv_output ? 0 : 18, |
917 | "<not counted>", csv_sep, | 925 | counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED, |
926 | csv_sep, | ||
918 | csv_output ? 0 : -24, | 927 | csv_output ? 0 : -24, |
919 | event_name(counter)); | 928 | event_name(counter)); |
920 | 929 | ||
@@ -1024,7 +1033,7 @@ static int stat__set_big_num(const struct option *opt __used, | |||
1024 | static const struct option options[] = { | 1033 | static const struct option options[] = { |
1025 | OPT_CALLBACK('e', "event", &evsel_list, "event", | 1034 | OPT_CALLBACK('e', "event", &evsel_list, "event", |
1026 | "event selector. use 'perf list' to list available events", | 1035 | "event selector. use 'perf list' to list available events", |
1027 | parse_events), | 1036 | parse_events_option), |
1028 | OPT_CALLBACK(0, "filter", &evsel_list, "filter", | 1037 | OPT_CALLBACK(0, "filter", &evsel_list, "filter", |
1029 | "event filter", parse_filter), | 1038 | "event filter", parse_filter), |
1030 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, | 1039 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, |
@@ -1035,6 +1044,8 @@ static const struct option options[] = { | |||
1035 | "stat events on existing thread id"), | 1044 | "stat events on existing thread id"), |
1036 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 1045 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
1037 | "system-wide collection from all CPUs"), | 1046 | "system-wide collection from all CPUs"), |
1047 | OPT_BOOLEAN('g', "group", &group, | ||
1048 | "put the counters into a counter group"), | ||
1038 | OPT_BOOLEAN('c', "scale", &scale, | 1049 | OPT_BOOLEAN('c', "scale", &scale, |
1039 | "scale/normalize counters"), | 1050 | "scale/normalize counters"), |
1040 | OPT_INCR('v', "verbose", &verbose, | 1051 | OPT_INCR('v', "verbose", &verbose, |