diff options
author | Ingo Molnar <mingo@elte.hu> | 2011-04-26 23:39:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-04-26 14:04:58 -0400 |
commit | a5d243d04a150acbfa79d641154f49e5d920f64f (patch) | |
tree | af1dc9b3a6b59c8aa5fd383f9bd2663e20975bb6 /tools/perf/builtin-stat.c | |
parent | f99844cb76b7d347711c22cdcb94266b7214141f (diff) |
perf stat: Print stalled cycles warning colors
Print the stalled-cycles percentage with different warning level ASCII colors,
as the percentage passes the 25%/50%/75% thresholds.
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/n/tip-e25zz44rcms7mu9az4fu5zp0@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 845ded8f15a2..e7d91f9cf789 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include "util/evlist.h" | 46 | #include "util/evlist.h" |
47 | #include "util/evsel.h" | 47 | #include "util/evsel.h" |
48 | #include "util/debug.h" | 48 | #include "util/debug.h" |
49 | #include "util/color.h" | ||
49 | #include "util/header.h" | 50 | #include "util/header.h" |
50 | #include "util/cpumap.h" | 51 | #include "util/cpumap.h" |
51 | #include "util/thread.h" | 52 | #include "util/thread.h" |
@@ -426,6 +427,29 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg) | |||
426 | fprintf(stderr, " # %8.3f CPUs utilized ", avg / avg_stats(&walltime_nsecs_stats)); | 427 | fprintf(stderr, " # %8.3f CPUs utilized ", avg / avg_stats(&walltime_nsecs_stats)); |
427 | } | 428 | } |
428 | 429 | ||
430 | static void print_stalled_cycles(int cpu, struct perf_evsel *evsel __used, double avg) | ||
431 | { | ||
432 | double total, ratio = 0.0; | ||
433 | const char *color; | ||
434 | |||
435 | total = avg_stats(&runtime_cycles_stats[cpu]); | ||
436 | |||
437 | if (total) | ||
438 | ratio = avg / total * 100.0; | ||
439 | |||
440 | color = PERF_COLOR_NORMAL; | ||
441 | if (ratio > 75.0) | ||
442 | color = PERF_COLOR_RED; | ||
443 | else if (ratio > 50.0) | ||
444 | color = PERF_COLOR_MAGENTA; | ||
445 | else if (ratio > 25.0) | ||
446 | color = PERF_COLOR_YELLOW; | ||
447 | |||
448 | fprintf(stderr, " # "); | ||
449 | color_fprintf(stderr, color, "%5.2f%%", ratio); | ||
450 | fprintf(stderr, " of all cycles are idle "); | ||
451 | } | ||
452 | |||
429 | static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | 453 | static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) |
430 | { | 454 | { |
431 | double total, ratio = 0.0; | 455 | double total, ratio = 0.0; |
@@ -488,12 +512,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | |||
488 | fprintf(stderr, " # %8.3f %% of all cache refs ", ratio); | 512 | fprintf(stderr, " # %8.3f %% of all cache refs ", ratio); |
489 | 513 | ||
490 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES)) { | 514 | } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES)) { |
491 | total = avg_stats(&runtime_cycles_stats[cpu]); | 515 | print_stalled_cycles(cpu, evsel, avg); |
492 | |||
493 | if (total) | ||
494 | ratio = avg / total * 100.0; | ||
495 | |||
496 | fprintf(stderr, " # %5.2f%% of all cycles are idle ", ratio); | ||
497 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { | 516 | } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { |
498 | total = avg_stats(&runtime_nsecs_stats[cpu]); | 517 | total = avg_stats(&runtime_nsecs_stats[cpu]); |
499 | 518 | ||
@@ -508,6 +527,8 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | |||
508 | ratio = 1000.0 * avg / total; | 527 | ratio = 1000.0 * avg / total; |
509 | 528 | ||
510 | fprintf(stderr, " # %8.3f M/sec ", ratio); | 529 | fprintf(stderr, " # %8.3f M/sec ", ratio); |
530 | } else { | ||
531 | fprintf(stderr, " "); | ||
511 | } | 532 | } |
512 | } | 533 | } |
513 | 534 | ||