20 #include <subcmd/parse-options.h> 27 #include <sys/prctl.h> 37 #ifdef HAVE_LIBNUMA_SUPPORT 38 static struct bench numa_benchmarks[] = {
39 {
"mem",
"Benchmark for NUMA workloads",
bench_numa },
40 {
"all",
"Run all NUMA benchmarks", NULL },
48 {
"all",
"Run all scheduler benchmarks", NULL },
55 {
"all",
"Run all memory access benchmarks", NULL },
66 {
"all",
"Run all futex benchmarks", NULL },
77 {
"sched",
"Scheduler and IPC benchmarks", sched_benchmarks },
78 {
"mem",
"Memory access benchmarks", mem_benchmarks },
79 #ifdef HAVE_LIBNUMA_SUPPORT 80 {
"numa",
"NUMA scheduling and MM benchmarks", numa_benchmarks },
82 {
"futex",
"Futex stressing benchmarks", futex_benchmarks },
83 {
"all",
"All benchmarks", NULL },
88 #define for_each_collection(coll) \ 89 for (coll = collections; coll->name; coll++) 92 #define for_each_bench(coll, bench) \ 93 for (bench = coll->benchmarks; bench && bench->name; bench++) 99 printf(
"\n # List of available benchmarks for collection '%s':\n\n", coll->
name);
114 OPT_STRING(
'f',
"format", &
bench_format_str,
"default|simple",
"Specify the output formatting style"),
115 OPT_UINTEGER(
'r',
"repeat", &
bench_repeat,
"Specify amount of times to repeat the run"),
120 "perf bench [<common options>] <collection> <benchmark> [<options>]",
134 printf(
" # List of all available benchmark collections:\n\n");
159 int argc,
const char **argv)
165 size = strlen(coll_name) + 1 + strlen(bench_name) + 1;
170 scnprintf(name, size,
"%s-%s", coll_name, bench_name);
175 ret =
fn(argc, argv);
198 printf(
"# Running %s/%s benchmark...\n", coll->
name, bench->
name);
201 argv[1] = bench->
name;
227 PARSE_OPT_STOP_AT_NON_OPTION);
236 printf(
"Invalid repeat option: Must specify a positive value\n");
245 if (!strcmp(argv[0],
"all")) {
253 if (strcmp(coll->
name, argv[0]))
262 if (!strcmp(argv[1],
"all")) {
268 if (strcmp(bench->
name, argv[1]))
272 printf(
"# Running '%s/%s' benchmark:\n", coll->
name, bench->
name);
278 if (!strcmp(argv[1],
"-h") || !strcmp(argv[1],
"--help")) {
283 printf(
"Unknown benchmark: '%s' for collection '%s'\n", argv[1], argv[0]);
288 printf(
"Unknown collection: '%s'\n", argv[0]);
#define for_each_collection(coll)
#define BENCH_FORMAT_SIMPLE_STR
int(* bench_fn_t)(int argc, const char **argv)
#define BENCH_FORMAT_UNKNOWN
int bench_futex_wake_parallel(int argc, const char **argv)
int bench_sched_pipe(int argc, const char **argv)
static struct bench futex_benchmarks[]
static const char * bench_format_str
static const char *const bench_usage[]
#define BENCH_FORMAT_DEFAULT_STR
#define BENCH_FORMAT_DEFAULT
static void print_usage(void)
int bench_futex_hash(int argc, const char **argv)
#define for_each_bench(coll, bench)
static void dump_benchmarks(struct collection *coll)
int bench_futex_lock_pi(int argc, const char **argv)
int bench_mem_memcpy(int argc, const char **argv)
static void run_all_collections(void)
static int str(yyscan_t scanner, int token)
int bench_sched_messaging(int argc, const char **argv)
int bench_futex_requeue(int argc, const char **argv)
static int bench_str2int(const char *str)
int bench_futex_wake(int argc, const char **argv)
int bench_mem_memset(int argc, const char **argv)
unsigned int bench_repeat
int bench_numa(int argc, const char **argv)
static struct bench mem_benchmarks[]
#define BENCH_FORMAT_SIMPLE
static void run_collection(struct collection *coll)
static const struct option bench_options[]
struct bench * benchmarks
int cmd_bench(int argc, const char **argv)
static int run_bench(const char *coll_name, const char *bench_name, bench_fn_t fn, int argc, const char **argv)
static struct bench sched_benchmarks[]
void static void * zalloc(size_t size)
static struct collection collections[]