diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2009-05-27 14:20:27 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-27 15:44:14 -0400 |
commit | 992444b173f35997f96f5cbb214f0de81d1b97ff (patch) | |
tree | 4d2634a8418d75289d8c0efdfb3f97c150934ac2 /Documentation/perf_counter/builtin-report.c | |
parent | 37f440cba299bb479cf45d12eef923f0979dbcaf (diff) |
perf_counter: tools: report: Add comm sorting
Signed-off-by: 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.129302022@chello.nl>
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.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c index 982abce0e7c1..a634022bae07 100644 --- a/Documentation/perf_counter/builtin-report.c +++ b/Documentation/perf_counter/builtin-report.c | |||
@@ -732,6 +732,35 @@ static struct sort_entry sort_thread = { | |||
732 | }; | 732 | }; |
733 | 733 | ||
734 | static int64_t | 734 | static int64_t |
735 | sort__comm_cmp(struct hist_entry *left, struct hist_entry *right) | ||
736 | { | ||
737 | char *comm_l = left->thread->comm; | ||
738 | char *comm_r = right->thread->comm; | ||
739 | |||
740 | if (!comm_l || !comm_r) { | ||
741 | if (!comm_l && !comm_r) | ||
742 | return 0; | ||
743 | else if (!comm_l) | ||
744 | return -1; | ||
745 | else | ||
746 | return 1; | ||
747 | } | ||
748 | |||
749 | return strcmp(comm_l, comm_r); | ||
750 | } | ||
751 | |||
752 | static size_t | ||
753 | sort__comm_print(FILE *fp, struct hist_entry *self) | ||
754 | { | ||
755 | return fprintf(fp, "%20s ", self->thread->comm ?: "<unknown>"); | ||
756 | } | ||
757 | |||
758 | static struct sort_entry sort_comm = { | ||
759 | .cmp = sort__comm_cmp, | ||
760 | .print = sort__comm_print, | ||
761 | }; | ||
762 | |||
763 | static int64_t | ||
735 | sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) | 764 | sort__sym_cmp(struct hist_entry *left, struct hist_entry *right) |
736 | { | 765 | { |
737 | uint64_t ip_l, ip_r; | 766 | uint64_t ip_l, ip_r; |
@@ -779,6 +808,7 @@ struct sort_dimension { | |||
779 | 808 | ||
780 | static struct sort_dimension sort_dimensions[] = { | 809 | static struct sort_dimension sort_dimensions[] = { |
781 | { .name = "pid", .entry = &sort_thread, }, | 810 | { .name = "pid", .entry = &sort_thread, }, |
811 | { .name = "comm", .entry = &sort_comm, }, | ||
782 | { .name = "symbol", .entry = &sort_sym, }, | 812 | { .name = "symbol", .entry = &sort_sym, }, |
783 | }; | 813 | }; |
784 | 814 | ||