Linux Perf
builtin-bench.c File Reference
#include "perf.h"
#include "util/util.h"
#include <subcmd/parse-options.h>
#include "builtin.h"
#include "bench/bench.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
Include dependency graph for builtin-bench.c:

Go to the source code of this file.

Classes

struct  bench
 
struct  collection
 

Macros

#define for_each_collection(coll)   for (coll = collections; coll->name; coll++)
 
#define for_each_bench(coll, bench)   for (bench = coll->benchmarks; bench && bench->name; bench++)
 

Typedefs

typedef int(* bench_fn_t) (int argc, const char **argv)
 

Functions

static void dump_benchmarks (struct collection *coll)
 
static void print_usage (void)
 
static int bench_str2int (const char *str)
 
static int run_bench (const char *coll_name, const char *bench_name, bench_fn_t fn, int argc, const char **argv)
 
static void run_collection (struct collection *coll)
 
static void run_all_collections (void)
 
int cmd_bench (int argc, const char **argv)
 

Variables

static struct bench sched_benchmarks []
 
static struct bench mem_benchmarks []
 
static struct bench futex_benchmarks []
 
static struct collection collections []
 
static const char * bench_format_str
 
int bench_format = BENCH_FORMAT_DEFAULT
 
unsigned int bench_repeat = 10
 
static const struct option bench_options []
 
static const char *const bench_usage []
 

Macro Definition Documentation

◆ for_each_bench

#define for_each_bench (   coll,
  bench 
)    for (bench = coll->benchmarks; bench && bench->name; bench++)

Definition at line 92 of file builtin-bench.c.

◆ for_each_collection

#define for_each_collection (   coll)    for (coll = collections; coll->name; coll++)

Definition at line 88 of file builtin-bench.c.

Typedef Documentation

◆ bench_fn_t

typedef int(* bench_fn_t) (int argc, const char **argv)

Definition at line 29 of file builtin-bench.c.

Function Documentation

◆ bench_str2int()

static int bench_str2int ( const char *  str)
static

Definition at line 141 of file builtin-bench.c.

◆ cmd_bench()

int cmd_bench ( int  argc,
const char **  argv 
)

Definition at line 215 of file builtin-bench.c.

Here is the call graph for this function:

◆ dump_benchmarks()

static void dump_benchmarks ( struct collection coll)
static

Definition at line 95 of file builtin-bench.c.

◆ print_usage()

static void print_usage ( void  )
static

Definition at line 124 of file builtin-bench.c.

◆ run_all_collections()

static void run_all_collections ( void  )
static

Definition at line 207 of file builtin-bench.c.

Here is the call graph for this function:

◆ run_bench()

static int run_bench ( const char *  coll_name,
const char *  bench_name,
bench_fn_t  fn,
int  argc,
const char **  argv 
)
static

Definition at line 158 of file builtin-bench.c.

Here is the call graph for this function:

◆ run_collection()

static void run_collection ( struct collection coll)
static

Definition at line 182 of file builtin-bench.c.

Here is the call graph for this function:

Variable Documentation

◆ bench_format

int bench_format = BENCH_FORMAT_DEFAULT

Definition at line 110 of file builtin-bench.c.

◆ bench_format_str

const char* bench_format_str
static

Definition at line 107 of file builtin-bench.c.

◆ bench_options

const struct option bench_options[]
static
Initial value:
= {
OPT_STRING('f', "format", &bench_format_str, "default|simple", "Specify the output formatting style"),
OPT_UINTEGER('r', "repeat", &bench_repeat, "Specify amount of times to repeat the run"),
}
static const char * bench_format_str
unsigned int bench_repeat

Definition at line 113 of file builtin-bench.c.

◆ bench_repeat

unsigned int bench_repeat = 10

Definition at line 111 of file builtin-bench.c.

◆ bench_usage

const char* const bench_usage[]
static
Initial value:
= {
"perf bench [<common options>] <collection> <benchmark> [<options>]",
NULL
}

Definition at line 119 of file builtin-bench.c.

◆ collections

struct collection collections[]
static
Initial value:
= {
{ "sched", "Scheduler and IPC benchmarks", sched_benchmarks },
{ "mem", "Memory access benchmarks", mem_benchmarks },
{"futex", "Futex stressing benchmarks", futex_benchmarks },
{ "all", "All benchmarks", NULL },
{ NULL, NULL, NULL }
}
static struct bench futex_benchmarks[]
Definition: builtin-bench.c:59
static struct bench mem_benchmarks[]
Definition: builtin-bench.c:52
static struct bench sched_benchmarks[]
Definition: builtin-bench.c:45

Definition at line 76 of file builtin-bench.c.

◆ futex_benchmarks

struct bench futex_benchmarks[]
static
Initial value:
= {
{ "hash", "Benchmark for futex hash table", bench_futex_hash },
{ "wake", "Benchmark for futex wake calls", bench_futex_wake },
{ "wake-parallel", "Benchmark for parallel futex wake calls", bench_futex_wake_parallel },
{ "requeue", "Benchmark for futex requeue calls", bench_futex_requeue },
{ "lock-pi", "Benchmark for futex lock_pi calls", bench_futex_lock_pi },
{ "all", "Run all futex benchmarks", NULL },
{ NULL, NULL, NULL }
}
int bench_futex_wake_parallel(int argc, const char **argv)
int bench_futex_hash(int argc, const char **argv)
Definition: futex-hash.c:118
int bench_futex_lock_pi(int argc, const char **argv)
int bench_futex_requeue(int argc, const char **argv)
int bench_futex_wake(int argc, const char **argv)
Definition: futex-wake.c:120

Definition at line 59 of file builtin-bench.c.

◆ mem_benchmarks

struct bench mem_benchmarks[]
static
Initial value:
= {
{ "memcpy", "Benchmark for memcpy() functions", bench_mem_memcpy },
{ "memset", "Benchmark for memset() functions", bench_mem_memset },
{ "all", "Run all memory access benchmarks", NULL },
{ NULL, NULL, NULL }
}
int bench_mem_memcpy(int argc, const char **argv)
int bench_mem_memset(int argc, const char **argv)

Definition at line 52 of file builtin-bench.c.

◆ sched_benchmarks

struct bench sched_benchmarks[]
static
Initial value:
= {
{ "messaging", "Benchmark for scheduling and IPC", bench_sched_messaging },
{ "pipe", "Benchmark for pipe() between two processes", bench_sched_pipe },
{ "all", "Run all scheduler benchmarks", NULL },
{ NULL, NULL, NULL }
}
int bench_sched_pipe(int argc, const char **argv)
Definition: sched-pipe.c:80
int bench_sched_messaging(int argc, const char **argv)

Definition at line 45 of file builtin-bench.c.