diff options
Diffstat (limited to 'tools/perf/ui/browsers/hists.c')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 122 |
1 files changed, 40 insertions, 82 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index b720b92eba6e..7ec871af3f6f 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -587,95 +587,52 @@ struct hpp_arg { | |||
587 | bool current_entry; | 587 | bool current_entry; |
588 | }; | 588 | }; |
589 | 589 | ||
590 | static int __hpp__color_callchain(struct hpp_arg *arg) | 590 | static int __hpp__overhead_callback(struct perf_hpp *hpp, bool front) |
591 | { | 591 | { |
592 | if (!symbol_conf.use_callchain) | ||
593 | return 0; | ||
594 | |||
595 | slsmg_printf("%c ", arg->folded_sign); | ||
596 | return 2; | ||
597 | } | ||
598 | |||
599 | static int __hpp__color_fmt(struct perf_hpp *hpp, struct hist_entry *he, | ||
600 | u64 (*get_field)(struct hist_entry *), | ||
601 | int (*callchain_cb)(struct hpp_arg *)) | ||
602 | { | ||
603 | int ret = 0; | ||
604 | double percent = 0.0; | ||
605 | struct hists *hists = he->hists; | ||
606 | struct hpp_arg *arg = hpp->ptr; | 592 | struct hpp_arg *arg = hpp->ptr; |
607 | 593 | ||
608 | if (hists->stats.total_period) | 594 | if (arg->current_entry && arg->b->navkeypressed) |
609 | percent = 100.0 * get_field(he) / hists->stats.total_period; | 595 | ui_browser__set_color(arg->b, HE_COLORSET_SELECTED); |
610 | 596 | else | |
611 | ui_browser__set_percent_color(arg->b, percent, arg->current_entry); | 597 | ui_browser__set_color(arg->b, HE_COLORSET_NORMAL); |
612 | |||
613 | if (callchain_cb) | ||
614 | ret += callchain_cb(arg); | ||
615 | |||
616 | ret += scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); | ||
617 | slsmg_printf("%s", hpp->buf); | ||
618 | |||
619 | if (symbol_conf.event_group) { | ||
620 | int prev_idx, idx_delta; | ||
621 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
622 | struct hist_entry *pair; | ||
623 | int nr_members = evsel->nr_members; | ||
624 | |||
625 | if (nr_members <= 1) | ||
626 | goto out; | ||
627 | 598 | ||
628 | prev_idx = perf_evsel__group_idx(evsel); | 599 | if (front) { |
600 | if (!symbol_conf.use_callchain) | ||
601 | return 0; | ||
629 | 602 | ||
630 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { | 603 | slsmg_printf("%c ", arg->folded_sign); |
631 | u64 period = get_field(pair); | 604 | return 2; |
632 | u64 total = pair->hists->stats.total_period; | 605 | } |
633 | 606 | ||
634 | if (!total) | 607 | return 0; |
635 | continue; | 608 | } |
636 | 609 | ||
637 | evsel = hists_to_evsel(pair->hists); | 610 | static int __hpp__color_callback(struct perf_hpp *hpp, bool front __maybe_unused) |
638 | idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1; | 611 | { |
612 | struct hpp_arg *arg = hpp->ptr; | ||
639 | 613 | ||
640 | while (idx_delta--) { | 614 | if (!arg->current_entry || !arg->b->navkeypressed) |
641 | /* | 615 | ui_browser__set_color(arg->b, HE_COLORSET_NORMAL); |
642 | * zero-fill group members in the middle which | 616 | return 0; |
643 | * have no sample | 617 | } |
644 | */ | ||
645 | ui_browser__set_percent_color(arg->b, 0.0, | ||
646 | arg->current_entry); | ||
647 | ret += scnprintf(hpp->buf, hpp->size, | ||
648 | " %6.2f%%", 0.0); | ||
649 | slsmg_printf("%s", hpp->buf); | ||
650 | } | ||
651 | 618 | ||
652 | percent = 100.0 * period / total; | 619 | static int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...) |
653 | ui_browser__set_percent_color(arg->b, percent, | 620 | { |
654 | arg->current_entry); | 621 | struct hpp_arg *arg = hpp->ptr; |
655 | ret += scnprintf(hpp->buf, hpp->size, | 622 | int ret; |
656 | " %6.2f%%", percent); | 623 | va_list args; |
657 | slsmg_printf("%s", hpp->buf); | 624 | double percent; |
658 | 625 | ||
659 | prev_idx = perf_evsel__group_idx(evsel); | 626 | va_start(args, fmt); |
660 | } | 627 | percent = va_arg(args, double); |
628 | va_end(args); | ||
661 | 629 | ||
662 | idx_delta = nr_members - prev_idx - 1; | 630 | ui_browser__set_percent_color(arg->b, percent, arg->current_entry); |
663 | 631 | ||
664 | while (idx_delta--) { | 632 | ret = scnprintf(hpp->buf, hpp->size, fmt, percent); |
665 | /* | 633 | slsmg_printf("%s", hpp->buf); |
666 | * zero-fill group members at last which have no sample | ||
667 | */ | ||
668 | ui_browser__set_percent_color(arg->b, 0.0, | ||
669 | arg->current_entry); | ||
670 | ret += scnprintf(hpp->buf, hpp->size, | ||
671 | " %6.2f%%", 0.0); | ||
672 | slsmg_printf("%s", hpp->buf); | ||
673 | } | ||
674 | } | ||
675 | out: | ||
676 | if (!arg->current_entry || !arg->b->navkeypressed) | ||
677 | ui_browser__set_color(arg->b, HE_COLORSET_NORMAL); | ||
678 | 634 | ||
635 | advance_hpp(hpp, ret); | ||
679 | return ret; | 636 | return ret; |
680 | } | 637 | } |
681 | 638 | ||
@@ -690,14 +647,15 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\ | |||
690 | struct perf_hpp *hpp, \ | 647 | struct perf_hpp *hpp, \ |
691 | struct hist_entry *he) \ | 648 | struct hist_entry *he) \ |
692 | { \ | 649 | { \ |
693 | return __hpp__color_fmt(hpp, he, __hpp_get_##_field, _cb); \ | 650 | return __hpp__fmt(hpp, he, __hpp_get_##_field, _cb, " %6.2f%%", \ |
651 | __hpp__slsmg_color_printf, true); \ | ||
694 | } | 652 | } |
695 | 653 | ||
696 | __HPP_COLOR_PERCENT_FN(overhead, period, __hpp__color_callchain) | 654 | __HPP_COLOR_PERCENT_FN(overhead, period, __hpp__overhead_callback) |
697 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, NULL) | 655 | __HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, __hpp__color_callback) |
698 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us, NULL) | 656 | __HPP_COLOR_PERCENT_FN(overhead_us, period_us, __hpp__color_callback) |
699 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, NULL) | 657 | __HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, __hpp__color_callback) |
700 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, NULL) | 658 | __HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, __hpp__color_callback) |
701 | 659 | ||
702 | #undef __HPP_COLOR_PERCENT_FN | 660 | #undef __HPP_COLOR_PERCENT_FN |
703 | 661 | ||