aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter/builtin-report.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-05-27 14:20:26 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-27 15:44:14 -0400
commit37f440cba299bb479cf45d12eef923f0979dbcaf (patch)
tree6a83d1c7a7a740ad485244267a3307aa48d3bc75 /Documentation/perf_counter/builtin-report.c
parent1aa167382323eeeeb38368cab85cf17979793cbe (diff)
pref_counter: tools: report: Add --sort option
option parsing for dynamic 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.041817692@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.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/Documentation/perf_counter/builtin-report.c b/Documentation/perf_counter/builtin-report.c
index 856186fd2bd4..982abce0e7c1 100644
--- a/Documentation/perf_counter/builtin-report.c
+++ b/Documentation/perf_counter/builtin-report.c
@@ -20,6 +20,7 @@
20 20
21static char const *input_name = "perf.data"; 21static char const *input_name = "perf.data";
22static char *vmlinux = NULL; 22static char *vmlinux = NULL;
23static char *sort_order = "pid,symbol";
23static int input; 24static int input;
24static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 25static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
25 26
@@ -770,12 +771,49 @@ static struct sort_entry sort_sym = {
770 .print = sort__sym_print, 771 .print = sort__sym_print,
771}; 772};
772 773
774struct sort_dimension {
775 char *name;
776 struct sort_entry *entry;
777 int taken;
778};
779
780static struct sort_dimension sort_dimensions[] = {
781 { .name = "pid", .entry = &sort_thread, },
782 { .name = "symbol", .entry = &sort_sym, },
783};
784
773static LIST_HEAD(hist_entry__sort_list); 785static LIST_HEAD(hist_entry__sort_list);
774 786
787static int sort_dimension__add(char *tok)
788{
789 int i;
790
791 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
792 struct sort_dimension *sd = &sort_dimensions[i];
793
794 if (sd->taken)
795 continue;
796
797 if (strcmp(tok, sd->name))
798 continue;
799
800 list_add_tail(&sd->entry->list, &hist_entry__sort_list);
801 sd->taken = 1;
802 return 0;
803 }
804
805 return -ESRCH;
806}
807
775static void setup_sorting(void) 808static void setup_sorting(void)
776{ 809{
777 list_add_tail(&sort_thread.list, &hist_entry__sort_list); 810 char *tmp, *tok, *str = strdup(sort_order);
778 list_add_tail(&sort_sym.list, &hist_entry__sort_list); 811
812 for (tok = strtok_r(str, ", ", &tmp);
813 tok; tok = strtok_r(NULL, ", ", &tmp))
814 sort_dimension__add(tok);
815
816 free(str);
779} 817}
780 818
781static int64_t 819static int64_t
@@ -1137,6 +1175,7 @@ static const struct option options[] = {
1137 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1175 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1138 "dump raw trace in ASCII"), 1176 "dump raw trace in ASCII"),
1139 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 1177 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
1178 OPT_STRING('s', "sort", &sort_order, "foo", "bar"),
1140 OPT_END() 1179 OPT_END()
1141}; 1180};
1142 1181