aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHitoshi Mitake <mitake@dcl.info.waseda.ac.jp>2009-11-04 19:31:34 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-08 04:19:18 -0500
commit629cc356653719c206a05f4dee5c5e242edb6546 (patch)
treea2aba27ecd8f97339a4f5a2ee8371209cc1e3aac /tools
parentc7d9300f367f480aee4663a0e3695c5b48859a1a (diff)
perf bench: Add builtin-bench.c: General framework for benchmark suites
This patch adds builtin-bench.c builtin-bench.c is a general framework for benchmark suites. Signed-off-by: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: fweisbec@gmail.com Cc: Jiri Kosina <jkosina@suse.cz> LKML-Reference: <1257381097-4743-5-git-send-email-mitake@dcl.info.waseda.ac.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-bench.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/tools/perf/builtin-bench.c b/tools/perf/builtin-bench.c
new file mode 100644
index 000000000000..31f41643b0cd
--- /dev/null
+++ b/tools/perf/builtin-bench.c
@@ -0,0 +1,128 @@
1/*
2 *
3 * builtin-bench.c
4 *
5 * General benchmarking subsystem provided by perf
6 *
7 * Copyright (C) 2009, Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
8 *
9 */
10
11/*
12 *
13 * Available subsystem list:
14 * sched ... scheduler and IPC mechanism
15 *
16 */
17
18#include "perf.h"
19#include "util/util.h"
20#include "util/parse-options.h"
21#include "builtin.h"
22#include "bench/bench.h"
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27
28struct bench_suite {
29 const char *name;
30 const char *summary;
31 int (*fn)(int, const char **, const char *);
32};
33
34static struct bench_suite sched_suites[] = {
35 { "messaging",
36 "Benchmark for scheduler and IPC mechanisms",
37 bench_sched_messaging },
38 { "pipe",
39 "Flood of communication over pipe() between two processes",
40 bench_sched_pipe },
41 { NULL,
42 NULL,
43 NULL }
44};
45
46struct bench_subsys {
47 const char *name;
48 const char *summary;
49 struct bench_suite *suites;
50};
51
52static struct bench_subsys subsystems[] = {
53 { "sched",
54 "scheduler and IPC mechanism",
55 sched_suites },
56 { NULL,
57 NULL,
58 NULL }
59};
60
61static void dump_suites(int subsys_index)
62{
63 int i;
64
65 printf("List of available suites for %s...\n\n",
66 subsystems[subsys_index].name);
67
68 for (i = 0; subsystems[subsys_index].suites[i].name; i++)
69 printf("\t%s: %s\n",
70 subsystems[subsys_index].suites[i].name,
71 subsystems[subsys_index].suites[i].summary);
72
73 printf("\n");
74 return;
75}
76
77int cmd_bench(int argc, const char **argv, const char *prefix __used)
78{
79 int i, j, status = 0;
80
81 if (argc < 2) {
82 /* No subsystem specified. */
83 printf("Usage: perf bench <subsystem> <suite> [<options>]\n\n");
84 printf("List of available subsystems...\n\n");
85
86 for (i = 0; subsystems[i].name; i++)
87 printf("\t%s: %s\n",
88 subsystems[i].name, subsystems[i].summary);
89 printf("\n");
90
91 goto end;
92 }
93
94 for (i = 0; subsystems[i].name; i++) {
95 if (strcmp(subsystems[i].name, argv[1]))
96 continue;
97
98 if (argc < 3) {
99 /* No suite specified. */
100 dump_suites(i);
101 goto end;
102 }
103
104 for (j = 0; subsystems[i].suites[j].name; j++) {
105 if (strcmp(subsystems[i].suites[j].name, argv[2]))
106 continue;
107
108 status = subsystems[i].suites[j].fn(argc - 2,
109 argv + 2, prefix);
110 goto end;
111 }
112
113 if (!strcmp(argv[2], "-h") || !strcmp(argv[2], "--help")) {
114 dump_suites(i);
115 goto end;
116 }
117
118 printf("Unknown suite:%s for %s\n", argv[2], argv[1]);
119 status = 1;
120 goto end;
121 }
122
123 printf("Unknown subsystem:%s\n", argv[1]);
124 status = 1;
125
126end:
127 return status;
128}