.. | .. |
---|
11 | 11 | * Available benchmark collection list: |
---|
12 | 12 | * |
---|
13 | 13 | * sched ... scheduler and IPC performance |
---|
| 14 | + * syscall ... System call performance |
---|
14 | 15 | * mem ... memory access performance |
---|
15 | 16 | * numa ... NUMA scheduling and MM performance |
---|
16 | 17 | * futex ... Futex performance |
---|
| 18 | + * epoll ... Event poll performance |
---|
17 | 19 | */ |
---|
18 | | -#include "perf.h" |
---|
19 | | -#include "util/util.h" |
---|
20 | 20 | #include <subcmd/parse-options.h> |
---|
21 | 21 | #include "builtin.h" |
---|
22 | 22 | #include "bench/bench.h" |
---|
23 | 23 | |
---|
| 24 | +#include <locale.h> |
---|
24 | 25 | #include <stdio.h> |
---|
25 | 26 | #include <stdlib.h> |
---|
26 | 27 | #include <string.h> |
---|
27 | 28 | #include <sys/prctl.h> |
---|
| 29 | +#include <linux/zalloc.h> |
---|
28 | 30 | |
---|
29 | 31 | typedef int (*bench_fn_t)(int argc, const char **argv); |
---|
30 | 32 | |
---|
.. | .. |
---|
49 | 51 | { NULL, NULL, NULL } |
---|
50 | 52 | }; |
---|
51 | 53 | |
---|
| 54 | +static struct bench syscall_benchmarks[] = { |
---|
| 55 | + { "basic", "Benchmark for basic getppid(2) calls", bench_syscall_basic }, |
---|
| 56 | + { "all", "Run all syscall benchmarks", NULL }, |
---|
| 57 | + { NULL, NULL, NULL }, |
---|
| 58 | +}; |
---|
| 59 | + |
---|
52 | 60 | static struct bench mem_benchmarks[] = { |
---|
53 | 61 | { "memcpy", "Benchmark for memcpy() functions", bench_mem_memcpy }, |
---|
54 | 62 | { "memset", "Benchmark for memset() functions", bench_mem_memset }, |
---|
| 63 | + { "find_bit", "Benchmark for find_bit() functions", bench_mem_find_bit }, |
---|
55 | 64 | { "all", "Run all memory access benchmarks", NULL }, |
---|
56 | 65 | { NULL, NULL, NULL } |
---|
57 | 66 | }; |
---|
.. | .. |
---|
67 | 76 | { NULL, NULL, NULL } |
---|
68 | 77 | }; |
---|
69 | 78 | |
---|
| 79 | +#ifdef HAVE_EVENTFD_SUPPORT |
---|
| 80 | +static struct bench epoll_benchmarks[] = { |
---|
| 81 | + { "wait", "Benchmark epoll concurrent epoll_waits", bench_epoll_wait }, |
---|
| 82 | + { "ctl", "Benchmark epoll concurrent epoll_ctls", bench_epoll_ctl }, |
---|
| 83 | + { "all", "Run all futex benchmarks", NULL }, |
---|
| 84 | + { NULL, NULL, NULL } |
---|
| 85 | +}; |
---|
| 86 | +#endif // HAVE_EVENTFD_SUPPORT |
---|
| 87 | + |
---|
| 88 | +static struct bench internals_benchmarks[] = { |
---|
| 89 | + { "synthesize", "Benchmark perf event synthesis", bench_synthesize }, |
---|
| 90 | + { "kallsyms-parse", "Benchmark kallsyms parsing", bench_kallsyms_parse }, |
---|
| 91 | + { "inject-build-id", "Benchmark build-id injection", bench_inject_build_id }, |
---|
| 92 | + { NULL, NULL, NULL } |
---|
| 93 | +}; |
---|
| 94 | + |
---|
70 | 95 | struct collection { |
---|
71 | 96 | const char *name; |
---|
72 | 97 | const char *summary; |
---|
.. | .. |
---|
75 | 100 | |
---|
76 | 101 | static struct collection collections[] = { |
---|
77 | 102 | { "sched", "Scheduler and IPC benchmarks", sched_benchmarks }, |
---|
| 103 | + { "syscall", "System call benchmarks", syscall_benchmarks }, |
---|
78 | 104 | { "mem", "Memory access benchmarks", mem_benchmarks }, |
---|
79 | 105 | #ifdef HAVE_LIBNUMA_SUPPORT |
---|
80 | 106 | { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, |
---|
81 | 107 | #endif |
---|
82 | 108 | {"futex", "Futex stressing benchmarks", futex_benchmarks }, |
---|
| 109 | +#ifdef HAVE_EVENTFD_SUPPORT |
---|
| 110 | + {"epoll", "Epoll stressing benchmarks", epoll_benchmarks }, |
---|
| 111 | +#endif |
---|
| 112 | + { "internals", "Perf-internals benchmarks", internals_benchmarks }, |
---|
83 | 113 | { "all", "All benchmarks", NULL }, |
---|
84 | 114 | { NULL, NULL, NULL } |
---|
85 | 115 | }; |
---|
.. | .. |
---|
196 | 226 | if (!bench->fn) |
---|
197 | 227 | break; |
---|
198 | 228 | printf("# Running %s/%s benchmark...\n", coll->name, bench->name); |
---|
199 | | - fflush(stdout); |
---|
200 | 229 | |
---|
201 | 230 | argv[1] = bench->name; |
---|
202 | 231 | run_bench(coll->name, bench->name, bench->fn, 1, argv); |
---|
.. | .. |
---|
216 | 245 | { |
---|
217 | 246 | struct collection *coll; |
---|
218 | 247 | int ret = 0; |
---|
| 248 | + |
---|
| 249 | + /* Unbuffered output */ |
---|
| 250 | + setvbuf(stdout, NULL, _IONBF, 0); |
---|
| 251 | + setlocale(LC_ALL, ""); |
---|
219 | 252 | |
---|
220 | 253 | if (argc < 2) { |
---|
221 | 254 | /* No collection specified. */ |
---|
.. | .. |
---|
270 | 303 | |
---|
271 | 304 | if (bench_format == BENCH_FORMAT_DEFAULT) |
---|
272 | 305 | printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name); |
---|
273 | | - fflush(stdout); |
---|
274 | 306 | ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1); |
---|
275 | 307 | goto end; |
---|
276 | 308 | } |
---|