diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 5e04fcc8d077..8420ec589506 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -59,42 +59,27 @@ static struct perf_counter_attr default_attrs[MAX_COUNTERS] = { | |||
59 | 59 | ||
60 | }; | 60 | }; |
61 | 61 | ||
62 | #define MAX_RUN 100 | ||
63 | |||
62 | static int system_wide = 0; | 64 | static int system_wide = 0; |
63 | static int inherit = 1; | ||
64 | static int verbose = 0; | 65 | static int verbose = 0; |
65 | |||
66 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; | ||
67 | |||
68 | static int target_pid = -1; | ||
69 | static int nr_cpus = 0; | 66 | static int nr_cpus = 0; |
70 | static unsigned int page_size; | 67 | static int run_idx = 0; |
71 | 68 | ||
69 | static int run_count = 1; | ||
70 | static int inherit = 1; | ||
72 | static int scale = 1; | 71 | static int scale = 1; |
72 | static int target_pid = -1; | ||
73 | 73 | ||
74 | static const unsigned int default_count[] = { | 74 | static int fd[MAX_NR_CPUS][MAX_COUNTERS]; |
75 | 1000000, | ||
76 | 1000000, | ||
77 | 10000, | ||
78 | 10000, | ||
79 | 1000000, | ||
80 | 10000, | ||
81 | }; | ||
82 | |||
83 | #define MAX_RUN 100 | ||
84 | |||
85 | static int run_count = 1; | ||
86 | static int run_idx = 0; | ||
87 | |||
88 | static u64 event_res[MAX_RUN][MAX_COUNTERS][3]; | ||
89 | static u64 event_scaled[MAX_RUN][MAX_COUNTERS]; | ||
90 | |||
91 | //static u64 event_hist[MAX_RUN][MAX_COUNTERS][3]; | ||
92 | |||
93 | 75 | ||
94 | static u64 runtime_nsecs[MAX_RUN]; | 76 | static u64 runtime_nsecs[MAX_RUN]; |
95 | static u64 walltime_nsecs[MAX_RUN]; | 77 | static u64 walltime_nsecs[MAX_RUN]; |
96 | static u64 runtime_cycles[MAX_RUN]; | 78 | static u64 runtime_cycles[MAX_RUN]; |
97 | 79 | ||
80 | static u64 event_res[MAX_RUN][MAX_COUNTERS][3]; | ||
81 | static u64 event_scaled[MAX_RUN][MAX_COUNTERS]; | ||
82 | |||
98 | static u64 event_res_avg[MAX_COUNTERS][3]; | 83 | static u64 event_res_avg[MAX_COUNTERS][3]; |
99 | static u64 event_res_noise[MAX_COUNTERS][3]; | 84 | static u64 event_res_noise[MAX_COUNTERS][3]; |
100 | 85 | ||
@@ -109,7 +94,6 @@ static u64 walltime_nsecs_noise; | |||
109 | static u64 runtime_cycles_avg; | 94 | static u64 runtime_cycles_avg; |
110 | static u64 runtime_cycles_noise; | 95 | static u64 runtime_cycles_noise; |
111 | 96 | ||
112 | |||
113 | #define ERR_PERF_OPEN \ | 97 | #define ERR_PERF_OPEN \ |
114 | "Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n" | 98 | "Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n" |
115 | 99 | ||
@@ -470,9 +454,9 @@ static const struct option options[] = { | |||
470 | OPT_INTEGER('p', "pid", &target_pid, | 454 | OPT_INTEGER('p', "pid", &target_pid, |
471 | "stat events on existing pid"), | 455 | "stat events on existing pid"), |
472 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 456 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
473 | "system-wide collection from all CPUs"), | 457 | "system-wide collection from all CPUs"), |
474 | OPT_BOOLEAN('S', "scale", &scale, | 458 | OPT_BOOLEAN('S', "scale", &scale, |
475 | "scale/normalize counters"), | 459 | "scale/normalize counters"), |
476 | OPT_BOOLEAN('v', "verbose", &verbose, | 460 | OPT_BOOLEAN('v', "verbose", &verbose, |
477 | "be more verbose (show counter open errors, etc)"), | 461 | "be more verbose (show counter open errors, etc)"), |
478 | OPT_INTEGER('r', "repeat", &run_count, | 462 | OPT_INTEGER('r', "repeat", &run_count, |
@@ -484,8 +468,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix) | |||
484 | { | 468 | { |
485 | int status; | 469 | int status; |
486 | 470 | ||
487 | page_size = sysconf(_SC_PAGE_SIZE); | ||
488 | |||
489 | memcpy(attrs, default_attrs, sizeof(attrs)); | 471 | memcpy(attrs, default_attrs, sizeof(attrs)); |
490 | 472 | ||
491 | argc = parse_options(argc, argv, options, stat_usage, 0); | 473 | argc = parse_options(argc, argv, options, stat_usage, 0); |
@@ -515,7 +497,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix) | |||
515 | status = 0; | 497 | status = 0; |
516 | for (run_idx = 0; run_idx < run_count; run_idx++) { | 498 | for (run_idx = 0; run_idx < run_count; run_idx++) { |
517 | if (run_count != 1 && verbose) | 499 | if (run_count != 1 && verbose) |
518 | fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx+1); | 500 | fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx + 1); |
519 | status = run_perf_stat(argc, argv); | 501 | status = run_perf_stat(argc, argv); |
520 | } | 502 | } |
521 | 503 | ||