diff options
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index e930b4e02335..7beedc6effa4 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | #include "util/util.h" | 10 | #include "util/util.h" |
11 | 11 | ||
12 | #include "util/color.h" | ||
12 | #include "util/list.h" | 13 | #include "util/list.h" |
13 | #include "util/cache.h" | 14 | #include "util/cache.h" |
14 | #include "util/rbtree.h" | 15 | #include "util/rbtree.h" |
@@ -548,7 +549,19 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples) | |||
548 | size_t ret; | 549 | size_t ret; |
549 | 550 | ||
550 | if (total_samples) { | 551 | if (total_samples) { |
551 | ret = fprintf(fp, " %6.2f%%", | 552 | double percent = self->count * 100.0 / total_samples; |
553 | char *color = PERF_COLOR_NORMAL; | ||
554 | |||
555 | /* | ||
556 | * We color high-overhead entries in red, low-overhead | ||
557 | * entries in green - and keep the middle ground normal: | ||
558 | */ | ||
559 | if (percent >= 5.0) | ||
560 | color = PERF_COLOR_RED; | ||
561 | if (percent < 0.5) | ||
562 | color = PERF_COLOR_GREEN; | ||
563 | |||
564 | ret = color_fprintf(fp, color, " %6.2f%%", | ||
552 | (self->count * 100.0) / total_samples); | 565 | (self->count * 100.0) / total_samples); |
553 | } else | 566 | } else |
554 | ret = fprintf(fp, "%12d ", self->count); | 567 | ret = fprintf(fp, "%12d ", self->count); |