diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 12:00:33 -0500 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 12:00:33 -0500 |
| commit | 3d14b5beba35250c548d3851a2b84fce742d8311 (patch) | |
| tree | 065e3d93c3fcbc5ee4c44fa78662393cddbdf6de /tools/perf/builtin-stat.c | |
| parent | 0719dc341389882cc834ed18fc9b7fc6006b2b85 (diff) | |
| parent | 1bf8e6219552d5dd27012d567ec8c4bb9c2d86b4 (diff) | |
Merge branch 'sa1100' into devel
Diffstat (limited to 'tools/perf/builtin-stat.c')
| -rw-r--r-- | tools/perf/builtin-stat.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3db31e7bf173..c70d72003557 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
| @@ -50,15 +50,17 @@ | |||
| 50 | 50 | ||
| 51 | static struct perf_event_attr default_attrs[] = { | 51 | static struct perf_event_attr default_attrs[] = { |
| 52 | 52 | ||
| 53 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, | 53 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, |
| 54 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES}, | 54 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES }, |
| 55 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS }, | 55 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS }, |
| 56 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS }, | 56 | { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS }, |
| 57 | 57 | ||
| 58 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES }, | 58 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES }, |
| 59 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS }, | 59 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS }, |
| 60 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_REFERENCES}, | 60 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS }, |
| 61 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_MISSES }, | 61 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES }, |
| 62 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_REFERENCES }, | ||
| 63 | { .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_MISSES }, | ||
| 62 | 64 | ||
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| @@ -125,6 +127,7 @@ struct stats event_res_stats[MAX_COUNTERS][3]; | |||
| 125 | struct stats runtime_nsecs_stats; | 127 | struct stats runtime_nsecs_stats; |
| 126 | struct stats walltime_nsecs_stats; | 128 | struct stats walltime_nsecs_stats; |
| 127 | struct stats runtime_cycles_stats; | 129 | struct stats runtime_cycles_stats; |
| 130 | struct stats runtime_branches_stats; | ||
| 128 | 131 | ||
| 129 | #define MATCH_EVENT(t, c, counter) \ | 132 | #define MATCH_EVENT(t, c, counter) \ |
| 130 | (attrs[counter].type == PERF_TYPE_##t && \ | 133 | (attrs[counter].type == PERF_TYPE_##t && \ |
| @@ -235,6 +238,8 @@ static void read_counter(int counter) | |||
| 235 | update_stats(&runtime_nsecs_stats, count[0]); | 238 | update_stats(&runtime_nsecs_stats, count[0]); |
| 236 | if (MATCH_EVENT(HARDWARE, HW_CPU_CYCLES, counter)) | 239 | if (MATCH_EVENT(HARDWARE, HW_CPU_CYCLES, counter)) |
| 237 | update_stats(&runtime_cycles_stats, count[0]); | 240 | update_stats(&runtime_cycles_stats, count[0]); |
| 241 | if (MATCH_EVENT(HARDWARE, HW_BRANCH_INSTRUCTIONS, counter)) | ||
| 242 | update_stats(&runtime_branches_stats, count[0]); | ||
| 238 | } | 243 | } |
| 239 | 244 | ||
| 240 | static int run_perf_stat(int argc __used, const char **argv) | 245 | static int run_perf_stat(int argc __used, const char **argv) |
| @@ -352,7 +357,16 @@ static void abs_printout(int counter, double avg) | |||
| 352 | ratio = avg / total; | 357 | ratio = avg / total; |
| 353 | 358 | ||
| 354 | fprintf(stderr, " # %10.3f IPC ", ratio); | 359 | fprintf(stderr, " # %10.3f IPC ", ratio); |
| 355 | } else { | 360 | } else if (MATCH_EVENT(HARDWARE, HW_BRANCH_MISSES, counter) && |
| 361 | runtime_branches_stats.n != 0) { | ||
| 362 | total = avg_stats(&runtime_branches_stats); | ||
| 363 | |||
| 364 | if (total) | ||
| 365 | ratio = avg * 100 / total; | ||
| 366 | |||
| 367 | fprintf(stderr, " # %10.3f %% ", ratio); | ||
| 368 | |||
| 369 | } else if (runtime_nsecs_stats.n != 0) { | ||
| 356 | total = avg_stats(&runtime_nsecs_stats); | 370 | total = avg_stats(&runtime_nsecs_stats); |
| 357 | 371 | ||
| 358 | if (total) | 372 | if (total) |
