提交 a5d243d0 编写于 作者: I Ingo Molnar

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: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/n/tip-e25zz44rcms7mu9az4fu5zp0@git.kernel.orgSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 f99844cb
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "util/evlist.h" #include "util/evlist.h"
#include "util/evsel.h" #include "util/evsel.h"
#include "util/debug.h" #include "util/debug.h"
#include "util/color.h"
#include "util/header.h" #include "util/header.h"
#include "util/cpumap.h" #include "util/cpumap.h"
#include "util/thread.h" #include "util/thread.h"
...@@ -426,6 +427,29 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg) ...@@ -426,6 +427,29 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
fprintf(stderr, " # %8.3f CPUs utilized ", avg / avg_stats(&walltime_nsecs_stats)); fprintf(stderr, " # %8.3f CPUs utilized ", avg / avg_stats(&walltime_nsecs_stats));
} }
static void print_stalled_cycles(int cpu, struct perf_evsel *evsel __used, double avg)
{
double total, ratio = 0.0;
const char *color;
total = avg_stats(&runtime_cycles_stats[cpu]);
if (total)
ratio = avg / total * 100.0;
color = PERF_COLOR_NORMAL;
if (ratio > 75.0)
color = PERF_COLOR_RED;
else if (ratio > 50.0)
color = PERF_COLOR_MAGENTA;
else if (ratio > 25.0)
color = PERF_COLOR_YELLOW;
fprintf(stderr, " # ");
color_fprintf(stderr, color, "%5.2f%%", ratio);
fprintf(stderr, " of all cycles are idle ");
}
static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
{ {
double total, ratio = 0.0; double total, ratio = 0.0;
...@@ -488,12 +512,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) ...@@ -488,12 +512,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
fprintf(stderr, " # %8.3f %% of all cache refs ", ratio); fprintf(stderr, " # %8.3f %% of all cache refs ", ratio);
} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES)) { } else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES)) {
total = avg_stats(&runtime_cycles_stats[cpu]); print_stalled_cycles(cpu, evsel, avg);
if (total)
ratio = avg / total * 100.0;
fprintf(stderr, " # %5.2f%% of all cycles are idle ", ratio);
} else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) { } else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
total = avg_stats(&runtime_nsecs_stats[cpu]); total = avg_stats(&runtime_nsecs_stats[cpu]);
...@@ -508,6 +527,8 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) ...@@ -508,6 +527,8 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
ratio = 1000.0 * avg / total; ratio = 1000.0 * avg / total;
fprintf(stderr, " # %8.3f M/sec ", ratio); fprintf(stderr, " # %8.3f M/sec ", ratio);
} else {
fprintf(stderr, " ");
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册