diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-05-27 15:36:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-27 15:40:47 -0400 |
commit | 2d65537ee7cd4a0818ea80a97ab7932368fff5cd (patch) | |
tree | 5e4c6fe7f95cfdf070d89b73da1fbc09baa6ba10 /Documentation/perf_counter | |
parent | 55e5ec41a9de46b6ca06031f4fbdfdfc76dc24dc (diff) |
pref_counter: tools: report: Add header printout & prettify
Old default output:
3.12% perf-report [.] ./perf-report: dsos__find
2.44% perf-report [k] kernel: kallsyms_expand_symbol
2.28% :4483 [.] <unknown>: <unknown>
2.05% :4174 [k] kernel: _spin_lock_irqsave
2.01% perf-report [k] kernel: vsnprintf
1.92% perf-report [k] kernel: format_decode
1.92% :4438 [k] kernel: _spin_lock
New default output:
#
# Overhead Command File: Symbol
# ........ ....... ............
#
6.54% perf [k] kernel: kallsyms_expand_symbol
6.26% perf [.] /home/mingo/tip/Documentation/perf_counter/perf: dso__insert_symbol
4.76% perf [.] /home/mingo/tip/Documentation/perf_counter/perf: hex2long
4.55% perf [k] kernel: number
4.48% perf [k] kernel: format_decode
4.09% perf [k] kernel: vsnprintf
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: John Kacur <jkacur@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <20090527182101.229504802@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter')
-rw-r--r-- | Documentation/perf_counter/builtin-report.c | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index 30e12c7f7108..6df95c2698c6 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -708,6 +708,7 @@ struct sort_entry { | |||
708 | struct list_head list; | 708 | struct list_head list; |
709 | 709 | ||
710 | int64_t (*cmp)(struct hist_entry *, struct hist_entry *); | 710 | int64_t (*cmp)(struct hist_entry *, struct hist_entry *); |
711 | size_t (*print_header)(FILE *fp); | ||
711 | size_t (*print)(FILE *fp, struct hist_entry *); | 712 | size_t (*print)(FILE *fp, struct hist_entry *); |
712 | }; | 713 | }; |
713 | 714 | ||
@@ -722,7 +723,7 @@ sort__thread_print(FILE *fp, struct hist_entry *self) | |||
722 | { | 723 | { |
723 | char bf[32]; | 724 | char bf[32]; |
724 | 725 | ||
725 | return fprintf(fp, "%14s ", | 726 | return fprintf(fp, " %16s", |
726 | thread__name(self->thread, bf, sizeof(bf))); | 727 | thread__name(self->thread, bf, sizeof(bf))); |
727 | } | 728 | } |
728 | 729 | ||
@@ -752,7 +753,7 @@ sort__comm_cmp(struct hist_entry *left, struct hist_entry *right) | |||
752 | static size_t | 753 | static size_t |
753 | sort__comm_print(FILE *fp, struct hist_entry *self) | 754 | sort__comm_print(FILE *fp, struct hist_entry *self) |
754 | { | 755 | { |
755 | return fprintf(fp, "%20s ", self->thread->comm ?: "<unknown>"); | 756 | return fprintf(fp, " %16s", self->thread->comm ?: "<unknown>"); |
756 | } | 757 | } |
757 | 758 | ||
758 | static struct sort_entry sort_comm = { | 759 | static struct sort_entry sort_comm = { |
@@ -781,7 +782,7 @@ sort__dso_cmp(struct hist_entry *left, struct hist_entry *right) | |||
781 | static size_t | 782 | static size_t |
782 | sort__dso_print(FILE *fp, struct hist_entry *self) | 783 | sort__dso_print(FILE *fp, struct hist_entry *self) |
783 | { | 784 | { |
784 | return fprintf(fp, "%64s ", self->dso ? self->dso->name : "<unknown>"); | 785 | return fprintf(fp, " %64s", self->dso ? self->dso->name : "<unknown>"); |
785 | } | 786 | } |
786 | 787 | ||
787 | static struct sort_entry sort_dso = { | 788 | static struct sort_entry sort_dso = { |
@@ -803,21 +804,33 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) | |||
803 | return (int64_t)(ip_r - ip_l); | 804 | return (int64_t)(ip_r - ip_l); |
804 | } | 805 | } |
805 | 806 | ||
807 | static size_t sort__sym_print_header(FILE *fp) | ||
808 | { | ||
809 | size_t ret = 0; | ||
810 | |||
811 | ret += fprintf(fp, "#\n"); | ||
812 | ret += fprintf(fp, "# Overhead Command File: Symbol\n"); | ||
813 | ret += fprintf(fp, "# ........ ....... ............\n"); | ||
814 | ret += fprintf(fp, "#\n"); | ||
815 | |||
816 | return ret; | ||
817 | } | ||
818 | |||
806 | static size_t | 819 | static size_t |
807 | sort__sym_print(FILE *fp, struct hist_entry *self) | 820 | sort__sym_print(FILE *fp, struct hist_entry *self) |
808 | { | 821 | { |
809 | size_t ret = 0; | 822 | size_t ret = 0; |
810 | 823 | ||
811 | ret += fprintf(fp, "[%c] ", self->level); | 824 | ret += fprintf(fp, " [%c] ", self->level); |
812 | 825 | ||
813 | if (verbose) | 826 | if (verbose) |
814 | ret += fprintf(fp, "%#018llx ", (unsigned long long)self->ip); | 827 | ret += fprintf(fp, " %#018llx", (unsigned long long)self->ip); |
815 | 828 | ||
816 | if (self->level != '.') | 829 | if (self->level != '.') |
817 | ret += fprintf(fp, "%s ", | 830 | ret += fprintf(fp, " kernel: %s", |
818 | self->sym ? self->sym->name : "<unknown>"); | 831 | self->sym ? self->sym->name : "<unknown>"); |
819 | else | 832 | else |
820 | ret += fprintf(fp, "%s: %s ", | 833 | ret += fprintf(fp, " %s: %s", |
821 | self->dso ? self->dso->name : "<unknown>", | 834 | self->dso ? self->dso->name : "<unknown>", |
822 | self->sym ? self->sym->name : "<unknown>"); | 835 | self->sym ? self->sym->name : "<unknown>"); |
823 | 836 | ||
@@ -825,8 +838,9 @@ sort__sym_print(FILE *fp, struct hist_entry *self) | |||
825 | } | 838 | } |
826 | 839 | ||
827 | static struct sort_entry sort_sym = { | 840 | static struct sort_entry sort_sym = { |
828 | .cmp = sort__sym_cmp, | 841 | .cmp = sort__sym_cmp, |
829 | .print = sort__sym_print, | 842 | .print_header = sort__sym_print_header, |
843 | .print = sort__sym_print, | ||
830 | }; | 844 | }; |
831 | 845 | ||
832 | struct sort_dimension { | 846 | struct sort_dimension { |
@@ -898,7 +912,7 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples) | |||
898 | size_t ret; | 912 | size_t ret; |
899 | 913 | ||
900 | if (total_samples) { | 914 | if (total_samples) { |
901 | ret = fprintf(fp, "%5.2f%% ", | 915 | ret = fprintf(fp, " %5.2f%%", |
902 | (self->count * 100.0) / total_samples); | 916 | (self->count * 100.0) / total_samples); |
903 | } else | 917 | } else |
904 | ret = fprintf(fp, "%12d ", self->count); | 918 | ret = fprintf(fp, "%12d ", self->count); |
@@ -1003,9 +1017,15 @@ static void output__resort(void) | |||
1003 | static size_t output__fprintf(FILE *fp, uint64_t total_samples) | 1017 | static size_t output__fprintf(FILE *fp, uint64_t total_samples) |
1004 | { | 1018 | { |
1005 | struct hist_entry *pos; | 1019 | struct hist_entry *pos; |
1020 | struct sort_entry *se; | ||
1006 | struct rb_node *nd; | 1021 | struct rb_node *nd; |
1007 | size_t ret = 0; | 1022 | size_t ret = 0; |
1008 | 1023 | ||
1024 | list_for_each_entry(se, &hist_entry__sort_list, list) { | ||
1025 | if (se->print_header) | ||
1026 | ret += se->print_header(fp); | ||
1027 | } | ||
1028 | |||
1009 | for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) { | 1029 | for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) { |
1010 | pos = rb_entry(nd, struct hist_entry, rb_node); | 1030 | pos = rb_entry(nd, struct hist_entry, rb_node); |
1011 | ret += hist_entry__fprintf(fp, pos, total_samples); | 1031 | ret += hist_entry__fprintf(fp, pos, total_samples); |