diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-06-14 14:19:16 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-15 09:46:39 -0400 |
commit | 7a72a2e5e6e06172ae26a3c5c8c89a5578f28432 (patch) | |
tree | 5331913b91c79080ec0407b2e19917c4691890db | |
parent | 5c854f3793c03539dcca48d8a89da9267127e436 (diff) |
perf stdio: Separate standard headers output
Introducing hists__fprintf_standard_headers function to separate
standard headers display code.
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-7-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 | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 7498ce25bce3..5d007836d9a7 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -638,23 +638,16 @@ hists__fprintf_hierarchy_headers(struct hists *hists, | |||
638 | return print_hierarchy_header(hists, hpp, symbol_conf.field_sep, fp); | 638 | return print_hierarchy_header(hists, hpp, symbol_conf.field_sep, fp); |
639 | } | 639 | } |
640 | 640 | ||
641 | static int hists__fprintf_headers(struct hists *hists, FILE *fp) | 641 | static int |
642 | hists__fprintf_standard_headers(struct hists *hists, | ||
643 | struct perf_hpp *hpp, | ||
644 | FILE *fp) | ||
642 | { | 645 | { |
643 | struct perf_hpp_fmt *fmt; | 646 | struct perf_hpp_fmt *fmt; |
644 | unsigned int width; | 647 | unsigned int width; |
645 | const char *sep = symbol_conf.field_sep; | 648 | const char *sep = symbol_conf.field_sep; |
646 | char bf[96]; | ||
647 | struct perf_hpp dummy_hpp = { | ||
648 | .buf = bf, | ||
649 | .size = sizeof(bf), | ||
650 | }; | ||
651 | bool first = true; | 649 | bool first = true; |
652 | 650 | ||
653 | fprintf(fp, "# "); | ||
654 | |||
655 | if (symbol_conf.report_hierarchy) | ||
656 | return hists__fprintf_hierarchy_headers(hists, &dummy_hpp, fp); | ||
657 | |||
658 | hists__for_each_format(hists, fmt) { | 651 | hists__for_each_format(hists, fmt) { |
659 | if (perf_hpp__should_skip(fmt, hists)) | 652 | if (perf_hpp__should_skip(fmt, hists)) |
660 | continue; | 653 | continue; |
@@ -664,8 +657,8 @@ static int hists__fprintf_headers(struct hists *hists, FILE *fp) | |||
664 | else | 657 | else |
665 | first = false; | 658 | first = false; |
666 | 659 | ||
667 | fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); | 660 | fmt->header(fmt, hpp, hists_to_evsel(hists)); |
668 | fprintf(fp, "%s", bf); | 661 | fprintf(fp, "%s", hpp->buf); |
669 | } | 662 | } |
670 | 663 | ||
671 | fprintf(fp, "\n"); | 664 | fprintf(fp, "\n"); |
@@ -688,7 +681,7 @@ static int hists__fprintf_headers(struct hists *hists, FILE *fp) | |||
688 | else | 681 | else |
689 | first = false; | 682 | first = false; |
690 | 683 | ||
691 | width = fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); | 684 | width = fmt->width(fmt, hpp, hists_to_evsel(hists)); |
692 | for (i = 0; i < width; i++) | 685 | for (i = 0; i < width; i++) |
693 | fprintf(fp, "."); | 686 | fprintf(fp, "."); |
694 | } | 687 | } |
@@ -698,6 +691,23 @@ static int hists__fprintf_headers(struct hists *hists, FILE *fp) | |||
698 | return 3; | 691 | return 3; |
699 | } | 692 | } |
700 | 693 | ||
694 | static int hists__fprintf_headers(struct hists *hists, FILE *fp) | ||
695 | { | ||
696 | char bf[96]; | ||
697 | struct perf_hpp dummy_hpp = { | ||
698 | .buf = bf, | ||
699 | .size = sizeof(bf), | ||
700 | }; | ||
701 | |||
702 | fprintf(fp, "# "); | ||
703 | |||
704 | if (symbol_conf.report_hierarchy) | ||
705 | return hists__fprintf_hierarchy_headers(hists, &dummy_hpp, fp); | ||
706 | else | ||
707 | return hists__fprintf_standard_headers(hists, &dummy_hpp, fp); | ||
708 | |||
709 | } | ||
710 | |||
701 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | 711 | size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, |
702 | int max_cols, float min_pcnt, FILE *fp) | 712 | int max_cols, float min_pcnt, FILE *fp) |
703 | { | 713 | { |