diff options
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index dd277897ff0b..24cca0a7ffa3 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -710,12 +710,16 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, | |||
710 | return ret; | 710 | return ret; |
711 | } | 711 | } |
712 | 712 | ||
713 | int hist_entry__fprintf(struct hist_entry *self, struct hists *hists, | 713 | int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists, |
714 | struct hists *pair_hists, bool show_displacement, | 714 | struct hists *pair_hists, bool show_displacement, |
715 | long displacement, FILE *fp, u64 session_total) | 715 | long displacement, FILE *fp, u64 session_total) |
716 | { | 716 | { |
717 | char bf[512]; | 717 | char bf[512]; |
718 | hist_entry__snprintf(self, bf, sizeof(bf), hists, pair_hists, | 718 | |
719 | if (size == 0 || size > sizeof(bf)) | ||
720 | size = sizeof(bf); | ||
721 | |||
722 | hist_entry__snprintf(he, bf, size, hists, pair_hists, | ||
719 | show_displacement, displacement, | 723 | show_displacement, displacement, |
720 | true, session_total); | 724 | true, session_total); |
721 | return fprintf(fp, "%s\n", bf); | 725 | return fprintf(fp, "%s\n", bf); |
@@ -739,7 +743,8 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self, | |||
739 | } | 743 | } |
740 | 744 | ||
741 | size_t hists__fprintf(struct hists *hists, struct hists *pair, | 745 | size_t hists__fprintf(struct hists *hists, struct hists *pair, |
742 | bool show_displacement, FILE *fp) | 746 | bool show_displacement, bool show_header, int max_rows, |
747 | int max_cols, FILE *fp) | ||
743 | { | 748 | { |
744 | struct sort_entry *se; | 749 | struct sort_entry *se; |
745 | struct rb_node *nd; | 750 | struct rb_node *nd; |
@@ -749,9 +754,13 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, | |||
749 | unsigned int width; | 754 | unsigned int width; |
750 | const char *sep = symbol_conf.field_sep; | 755 | const char *sep = symbol_conf.field_sep; |
751 | const char *col_width = symbol_conf.col_width_list_str; | 756 | const char *col_width = symbol_conf.col_width_list_str; |
757 | int nr_rows = 0; | ||
752 | 758 | ||
753 | init_rem_hits(); | 759 | init_rem_hits(); |
754 | 760 | ||
761 | if (!show_header) | ||
762 | goto print_entries; | ||
763 | |||
755 | fprintf(fp, "# %s", pair ? "Baseline" : "Overhead"); | 764 | fprintf(fp, "# %s", pair ? "Baseline" : "Overhead"); |
756 | 765 | ||
757 | if (symbol_conf.show_nr_samples) { | 766 | if (symbol_conf.show_nr_samples) { |
@@ -814,7 +823,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, | |||
814 | width = hists__col_len(hists, se->se_width_idx); | 823 | width = hists__col_len(hists, se->se_width_idx); |
815 | fprintf(fp, " %*s", width, se->se_header); | 824 | fprintf(fp, " %*s", width, se->se_header); |
816 | } | 825 | } |
826 | |||
817 | fprintf(fp, "\n"); | 827 | fprintf(fp, "\n"); |
828 | if (max_rows && ++nr_rows >= max_rows) | ||
829 | goto out; | ||
818 | 830 | ||
819 | if (sep) | 831 | if (sep) |
820 | goto print_entries; | 832 | goto print_entries; |
@@ -841,7 +853,13 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair, | |||
841 | fprintf(fp, "."); | 853 | fprintf(fp, "."); |
842 | } | 854 | } |
843 | 855 | ||
844 | fprintf(fp, "\n#\n"); | 856 | fprintf(fp, "\n"); |
857 | if (max_rows && ++nr_rows >= max_rows) | ||
858 | goto out; | ||
859 | |||
860 | fprintf(fp, "#\n"); | ||
861 | if (max_rows && ++nr_rows >= max_rows) | ||
862 | goto out; | ||
845 | 863 | ||
846 | print_entries: | 864 | print_entries: |
847 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 865 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
@@ -858,19 +876,22 @@ print_entries: | |||
858 | displacement = 0; | 876 | displacement = 0; |
859 | ++position; | 877 | ++position; |
860 | } | 878 | } |
861 | ret += hist_entry__fprintf(h, hists, pair, show_displacement, | 879 | ret += hist_entry__fprintf(h, max_cols, hists, pair, show_displacement, |
862 | displacement, fp, hists->stats.total_period); | 880 | displacement, fp, hists->stats.total_period); |
863 | 881 | ||
864 | if (symbol_conf.use_callchain) | 882 | if (symbol_conf.use_callchain) |
865 | ret += hist_entry__fprintf_callchain(h, hists, fp, | 883 | ret += hist_entry__fprintf_callchain(h, hists, fp, |
866 | hists->stats.total_period); | 884 | hists->stats.total_period); |
885 | if (max_rows && ++nr_rows >= max_rows) | ||
886 | goto out; | ||
887 | |||
867 | if (h->ms.map == NULL && verbose > 1) { | 888 | if (h->ms.map == NULL && verbose > 1) { |
868 | __map_groups__fprintf_maps(&h->thread->mg, | 889 | __map_groups__fprintf_maps(&h->thread->mg, |
869 | MAP__FUNCTION, verbose, fp); | 890 | MAP__FUNCTION, verbose, fp); |
870 | fprintf(fp, "%.10s end\n", graph_dotted_line); | 891 | fprintf(fp, "%.10s end\n", graph_dotted_line); |
871 | } | 892 | } |
872 | } | 893 | } |
873 | 894 | out: | |
874 | free(rem_sq_bracket); | 895 | free(rem_sq_bracket); |
875 | 896 | ||
876 | return ret; | 897 | return ret; |