diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index e7d91f9cf789..5d4e1b9b2d89 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -450,6 +450,29 @@ static void print_stalled_cycles(int cpu, struct perf_evsel *evsel __used, doubl | |||
450 | fprintf(stderr, " of all cycles are idle "); | 450 | fprintf(stderr, " of all cycles are idle "); |
451 | } | 451 | } |
452 | 452 | ||
453 | static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double avg) | ||
454 | { | ||
455 | double total, ratio = 0.0; | ||
456 | const char *color; | ||
457 | |||
458 | total = avg_stats(&runtime_branches_stats[cpu]); | ||
459 | |||
460 | if (total) | ||
461 | ratio = avg / total * 100.0; | ||
462 | |||
463 | color = PERF_COLOR_NORMAL; | ||
464 | if (ratio > 20.0) | ||
465 | color = PERF_COLOR_RED; | ||
466 | else if (ratio > 10.0) | ||
467 | color = PERF_COLOR_MAGENTA; | ||
468 | else if (ratio > 5.0) | ||
469 | color = PERF_COLOR_YELLOW; | ||
470 | |||
471 | fprintf(stderr, " # "); | ||
472 | color_fprintf(stderr, color, "%5.2f%%", ratio); | ||
473 | fprintf(stderr, " of all branches "); | ||
474 | } | ||
475 | |||
453 | static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | 476 | static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) |
454 | { | 477 | { |
455 | double total, ratio = 0.0; | 478 | double total, ratio = 0.0; |
@@ -495,13 +518,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | |||
495 | 518 | ||
496 | } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) && | 519 | } else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) && |
497 | runtime_branches_stats[cpu].n != 0) { | 520 | runtime_branches_stats[cpu].n != 0) { |
498 | total = avg_stats(&runtime_branches_stats[cpu]); | 521 | print_branch_misses(cpu, evsel, avg); |
499 | |||
500 | if (total) | ||
501 | ratio = avg * 100 / total; | ||
502 | |||
503 | fprintf(stderr, " # %5.2f %% of all branches ", ratio); | ||
504 | |||
505 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) && | 522 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) && |
506 | runtime_cacherefs_stats[cpu].n != 0) { | 523 | runtime_cacherefs_stats[cpu].n != 0) { |
507 | total = avg_stats(&runtime_cacherefs_stats[cpu]); | 524 | total = avg_stats(&runtime_cacherefs_stats[cpu]); |