aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter/builtin-report.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-05-28 05:08:33 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-28 05:47:02 -0400
commitca8cdeef9ca2ff89ee8a21d6f6ff3dfb60286041 (patch)
tree9fd7bffefdb8e0f4a10ba3a1dbdfad293dc9ebc7 /Documentation/perf_counter/builtin-report.c
parentd3e78ee3d015dac1794433abb6403b6fc8e70e10 (diff)
perf_counter tools: report: Implement header output for --sort variants
Implement this style of header: # # Overhead Command File: Symbol # ........ ....... ............ # for the various --sort variants as well. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: John Kacur <jkacur@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-report.c')
-rw-r--r--Documentation/perf_counter/builtin-report.c70
1 files changed, 28 insertions, 42 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index 5993c129d736..506cde437b78 100644
--- a/Documentation/perf_counter/builtin-report.c
+++ b/Documentation/perf_counter/builtin-report.c
@@ -596,8 +596,6 @@ out_delete:
596 596
597struct thread; 597struct thread;
598 598
599static const char *thread__name(struct thread *self, char *bf, size_t size);
600
601struct thread { 599struct thread {
602 struct rb_node rb_node; 600 struct rb_node rb_node;
603 struct list_head maps; 601 struct list_head maps;
@@ -605,15 +603,6 @@ struct thread {
605 char *comm; 603 char *comm;
606}; 604};
607 605
608static const char *thread__name(struct thread *self, char *bf, size_t size)
609{
610 if (self->comm)
611 return self->comm;
612
613 snprintf(bf, sizeof(bf), ":%u", self->pid);
614 return bf;
615}
616
617static struct thread *thread__new(pid_t pid) 606static struct thread *thread__new(pid_t pid)
618{ 607{
619 struct thread *self = malloc(sizeof(*self)); 608 struct thread *self = malloc(sizeof(*self));
@@ -707,8 +696,9 @@ struct hist_entry {
707struct sort_entry { 696struct sort_entry {
708 struct list_head list; 697 struct list_head list;
709 698
699 char *header;
700
710 int64_t (*cmp)(struct hist_entry *, struct hist_entry *); 701 int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
711 size_t (*print_header)(FILE *fp);
712 size_t (*print)(FILE *fp, struct hist_entry *); 702 size_t (*print)(FILE *fp, struct hist_entry *);
713}; 703};
714 704
@@ -721,13 +711,11 @@ sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
721static size_t 711static size_t
722sort__thread_print(FILE *fp, struct hist_entry *self) 712sort__thread_print(FILE *fp, struct hist_entry *self)
723{ 713{
724 char bf[32]; 714 return fprintf(fp, " %16s:%5d", self->thread->comm ?: "", self->thread->pid);
725
726 return fprintf(fp, " %16s",
727 thread__name(self->thread, bf, sizeof(bf)));
728} 715}
729 716
730static struct sort_entry sort_thread = { 717static struct sort_entry sort_thread = {
718 .header = " Command: Pid ",
731 .cmp = sort__thread_cmp, 719 .cmp = sort__thread_cmp,
732 .print = sort__thread_print, 720 .print = sort__thread_print,
733}; 721};
@@ -757,6 +745,7 @@ sort__comm_print(FILE *fp, struct hist_entry *self)
757} 745}
758 746
759static struct sort_entry sort_comm = { 747static struct sort_entry sort_comm = {
748 .header = " Command",
760 .cmp = sort__comm_cmp, 749 .cmp = sort__comm_cmp,
761 .print = sort__comm_print, 750 .print = sort__comm_print,
762}; 751};
@@ -786,6 +775,7 @@ sort__dso_print(FILE *fp, struct hist_entry *self)
786} 775}
787 776
788static struct sort_entry sort_dso = { 777static struct sort_entry sort_dso = {
778 .header = " Shared Object",
789 .cmp = sort__dso_cmp, 779 .cmp = sort__dso_cmp,
790 .print = sort__dso_print, 780 .print = sort__dso_print,
791}; 781};
@@ -804,43 +794,25 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
804 return (int64_t)(ip_r - ip_l); 794 return (int64_t)(ip_r - ip_l);
805} 795}
806 796
807static 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
819static size_t 797static size_t
820sort__sym_print(FILE *fp, struct hist_entry *self) 798sort__sym_print(FILE *fp, struct hist_entry *self)
821{ 799{
822 size_t ret = 0; 800 size_t ret = 0;
823 801
824 ret += fprintf(fp, " [%c] ", self->level);
825
826 if (verbose) 802 if (verbose)
827 ret += fprintf(fp, " %#018llx", (unsigned long long)self->ip); 803 ret += fprintf(fp, " %#018llx", (unsigned long long)self->ip);
828 804
829 if (self->level != '.') 805 ret += fprintf(fp, " %s: %s",
830 ret += fprintf(fp, " kernel: %s", 806 self->dso ? self->dso->name : "<unknown>",
831 self->sym ? self->sym->name : "<unknown>"); 807 self->sym ? self->sym->name : "<unknown>");
832 else
833 ret += fprintf(fp, " %s: %s",
834 self->dso ? self->dso->name : "<unknown>",
835 self->sym ? self->sym->name : "<unknown>");
836 808
837 return ret; 809 return ret;
838} 810}
839 811
840static struct sort_entry sort_sym = { 812static struct sort_entry sort_sym = {
841 .cmp = sort__sym_cmp, 813 .header = "Shared Object: Symbol",
842 .print_header = sort__sym_print_header, 814 .cmp = sort__sym_cmp,
843 .print = sort__sym_print, 815 .print = sort__sym_print,
844}; 816};
845 817
846struct sort_dimension { 818struct sort_dimension {
@@ -1021,10 +993,24 @@ static size_t output__fprintf(FILE *fp, uint64_t total_samples)
1021 struct rb_node *nd; 993 struct rb_node *nd;
1022 size_t ret = 0; 994 size_t ret = 0;
1023 995
996 fprintf(fp, "#\n");
997
998 fprintf(fp, "# Overhead");
999 list_for_each_entry(se, &hist_entry__sort_list, list)
1000 fprintf(fp, " %s", se->header);
1001 fprintf(fp, "\n");
1002
1003 fprintf(fp, "# ........");
1024 list_for_each_entry(se, &hist_entry__sort_list, list) { 1004 list_for_each_entry(se, &hist_entry__sort_list, list) {
1025 if (se->print_header) 1005 int i;
1026 ret += se->print_header(fp); 1006
1007 fprintf(fp, " ");
1008 for (i = 0; i < strlen(se->header); i++)
1009 fprintf(fp, ".");
1027 } 1010 }
1011 fprintf(fp, "\n");
1012
1013 fprintf(fp, "#\n");
1028 1014
1029 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) { 1015 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
1030 pos = rb_entry(nd, struct hist_entry, rb_node); 1016 pos = rb_entry(nd, struct hist_entry, rb_node);