diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-06-14 14:19:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-15 09:44:26 -0400 |
commit | 36592ebb73782aa2304a71f9a3b586566c2892ee (patch) | |
tree | 8033f629d10100497007aaa553c33d8e4b0608d2 | |
parent | 01b4770d5654fcb71645a1ee095759c255048466 (diff) |
perf stdio: Separate headers output
Introducing hists__fprintf_headers function to separate the code that
displays headers.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1465928361-2442-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 560eb47d56f9..91353ca16d04 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -622,36 +622,18 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, | |||
622 | return 2; | 622 | return 2; |
623 | } | 623 | } |
624 | 624 | ||
625 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | 625 | static int hists__fprintf_headers(struct hists *hists, FILE *fp) |
626 | int max_cols, float min_pcnt, FILE *fp) | ||
627 | { | 626 | { |
628 | struct perf_hpp_fmt *fmt; | 627 | struct perf_hpp_fmt *fmt; |
629 | struct perf_hpp_list_node *fmt_node; | 628 | struct perf_hpp_list_node *fmt_node; |
630 | struct rb_node *nd; | ||
631 | size_t ret = 0; | ||
632 | unsigned int width; | 629 | unsigned int width; |
633 | const char *sep = symbol_conf.field_sep; | 630 | const char *sep = symbol_conf.field_sep; |
634 | int nr_rows = 0; | ||
635 | char bf[96]; | 631 | char bf[96]; |
636 | struct perf_hpp dummy_hpp = { | 632 | struct perf_hpp dummy_hpp = { |
637 | .buf = bf, | 633 | .buf = bf, |
638 | .size = sizeof(bf), | 634 | .size = sizeof(bf), |
639 | }; | 635 | }; |
640 | bool first = true; | 636 | bool first = true; |
641 | size_t linesz; | ||
642 | char *line = NULL; | ||
643 | unsigned indent; | ||
644 | |||
645 | init_rem_hits(); | ||
646 | |||
647 | hists__for_each_format(hists, fmt) | ||
648 | perf_hpp__reset_width(fmt, hists); | ||
649 | |||
650 | if (symbol_conf.col_width_list_str) | ||
651 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | ||
652 | |||
653 | if (!show_header) | ||
654 | goto print_entries; | ||
655 | 637 | ||
656 | fprintf(fp, "# "); | 638 | fprintf(fp, "# "); |
657 | 639 | ||
@@ -660,8 +642,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
660 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) | 642 | perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) |
661 | perf_hpp__reset_width(fmt, hists); | 643 | perf_hpp__reset_width(fmt, hists); |
662 | } | 644 | } |
663 | nr_rows += print_hierarchy_header(hists, &dummy_hpp, sep, fp); | 645 | return print_hierarchy_header(hists, &dummy_hpp, sep, fp); |
664 | goto print_entries; | ||
665 | } | 646 | } |
666 | 647 | ||
667 | hists__for_each_format(hists, fmt) { | 648 | hists__for_each_format(hists, fmt) { |
@@ -678,11 +659,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
678 | } | 659 | } |
679 | 660 | ||
680 | fprintf(fp, "\n"); | 661 | fprintf(fp, "\n"); |
681 | if (max_rows && ++nr_rows >= max_rows) | ||
682 | goto out; | ||
683 | 662 | ||
684 | if (sep) | 663 | if (sep) |
685 | goto print_entries; | 664 | return 1; |
686 | 665 | ||
687 | first = true; | 666 | first = true; |
688 | 667 | ||
@@ -705,14 +684,36 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
705 | } | 684 | } |
706 | 685 | ||
707 | fprintf(fp, "\n"); | 686 | fprintf(fp, "\n"); |
708 | if (max_rows && ++nr_rows >= max_rows) | ||
709 | goto out; | ||
710 | |||
711 | fprintf(fp, "#\n"); | 687 | fprintf(fp, "#\n"); |
712 | if (max_rows && ++nr_rows >= max_rows) | 688 | return 3; |
689 | } | ||
690 | |||
691 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | ||
692 | int max_cols, float min_pcnt, FILE *fp) | ||
693 | { | ||
694 | struct perf_hpp_fmt *fmt; | ||
695 | struct rb_node *nd; | ||
696 | size_t ret = 0; | ||
697 | const char *sep = symbol_conf.field_sep; | ||
698 | int nr_rows = 0; | ||
699 | size_t linesz; | ||
700 | char *line = NULL; | ||
701 | unsigned indent; | ||
702 | |||
703 | init_rem_hits(); | ||
704 | |||
705 | hists__for_each_format(hists, fmt) | ||
706 | perf_hpp__reset_width(fmt, hists); | ||
707 | |||
708 | if (symbol_conf.col_width_list_str) | ||
709 | perf_hpp__set_user_width(symbol_conf.col_width_list_str); | ||
710 | |||
711 | if (show_header) | ||
712 | nr_rows += hists__fprintf_headers(hists, fp); | ||
713 | |||
714 | if (max_rows && nr_rows >= max_rows) | ||
713 | goto out; | 715 | goto out; |
714 | 716 | ||
715 | print_entries: | ||
716 | linesz = hists__sort_list_width(hists) + 3 + 1; | 717 | linesz = hists__sort_list_width(hists) + 3 + 1; |
717 | linesz += perf_hpp__color_overhead(); | 718 | linesz += perf_hpp__color_overhead(); |
718 | line = malloc(linesz); | 719 | line = malloc(linesz); |