Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 2 | /* |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 3 | * builtin-bench.c |
| 4 | * |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 5 | * General benchmarking collections provided by perf |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 6 | * |
| 7 | * Copyright (C) 2009, Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | /* |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 11 | * Available benchmark collection list: |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 12 | * |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 13 | * sched ... scheduler and IPC performance |
Hitoshi Mitake | 827f3b4 | 2009-11-18 00:20:09 +0900 | [diff] [blame] | 14 | * mem ... memory access performance |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 15 | * numa ... NUMA scheduling and MM performance |
Davidlohr Bueso | a043971 | 2013-12-14 20:31:55 -0800 | [diff] [blame] | 16 | * futex ... Futex performance |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 17 | */ |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 18 | #include "perf.h" |
| 19 | #include "util/util.h" |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 20 | #include <subcmd/parse-options.h> |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 21 | #include "builtin.h" |
| 22 | #include "bench/bench.h" |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 27 | #include <sys/prctl.h> |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 28 | |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 29 | typedef int (*bench_fn_t)(int argc, const char **argv); |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 30 | |
| 31 | struct bench { |
| 32 | const char *name; |
| 33 | const char *summary; |
| 34 | bench_fn_t fn; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 35 | }; |
| 36 | |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 37 | #ifdef HAVE_LIBNUMA_SUPPORT |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 38 | static struct bench numa_benchmarks[] = { |
| 39 | { "mem", "Benchmark for NUMA workloads", bench_numa }, |
Ingo Molnar | aa254af | 2015-10-19 10:04:30 +0200 | [diff] [blame] | 40 | { "all", "Run all NUMA benchmarks", NULL }, |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 41 | { NULL, NULL, NULL } |
Ingo Molnar | 1c13f3c | 2012-12-06 13:51:59 +0100 | [diff] [blame] | 42 | }; |
Peter Hurley | 79d824e | 2013-01-27 20:51:22 -0500 | [diff] [blame] | 43 | #endif |
Ingo Molnar | 1c13f3c | 2012-12-06 13:51:59 +0100 | [diff] [blame] | 44 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 45 | static struct bench sched_benchmarks[] = { |
| 46 | { "messaging", "Benchmark for scheduling and IPC", bench_sched_messaging }, |
| 47 | { "pipe", "Benchmark for pipe() between two processes", bench_sched_pipe }, |
Ingo Molnar | aa254af | 2015-10-19 10:04:30 +0200 | [diff] [blame] | 48 | { "all", "Run all scheduler benchmarks", NULL }, |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 49 | { NULL, NULL, NULL } |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 50 | }; |
| 51 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 52 | static struct bench mem_benchmarks[] = { |
Ingo Molnar | 13b1fdc | 2015-10-19 10:04:26 +0200 | [diff] [blame] | 53 | { "memcpy", "Benchmark for memcpy() functions", bench_mem_memcpy }, |
| 54 | { "memset", "Benchmark for memset() functions", bench_mem_memset }, |
Ingo Molnar | aa254af | 2015-10-19 10:04:30 +0200 | [diff] [blame] | 55 | { "all", "Run all memory access benchmarks", NULL }, |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 56 | { NULL, NULL, NULL } |
Hitoshi Mitake | 827f3b4 | 2009-11-18 00:20:09 +0900 | [diff] [blame] | 57 | }; |
| 58 | |
Davidlohr Bueso | a043971 | 2013-12-14 20:31:55 -0800 | [diff] [blame] | 59 | static struct bench futex_benchmarks[] = { |
| 60 | { "hash", "Benchmark for futex hash table", bench_futex_hash }, |
Davidlohr Bueso | 27db783 | 2013-12-14 20:31:56 -0800 | [diff] [blame] | 61 | { "wake", "Benchmark for futex wake calls", bench_futex_wake }, |
Davidlohr Bueso | d65817b | 2015-05-08 11:37:59 -0700 | [diff] [blame] | 62 | { "wake-parallel", "Benchmark for parallel futex wake calls", bench_futex_wake_parallel }, |
Davidlohr Bueso | 0fb298c | 2013-12-14 20:31:57 -0800 | [diff] [blame] | 63 | { "requeue", "Benchmark for futex requeue calls", bench_futex_requeue }, |
Davidlohr Bueso | d2f3f5d | 2015-07-07 01:55:53 -0700 | [diff] [blame] | 64 | /* pi-futexes */ |
| 65 | { "lock-pi", "Benchmark for futex lock_pi calls", bench_futex_lock_pi }, |
Ingo Molnar | aa254af | 2015-10-19 10:04:30 +0200 | [diff] [blame] | 66 | { "all", "Run all futex benchmarks", NULL }, |
Davidlohr Bueso | a043971 | 2013-12-14 20:31:55 -0800 | [diff] [blame] | 67 | { NULL, NULL, NULL } |
| 68 | }; |
| 69 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 70 | struct collection { |
| 71 | const char *name; |
| 72 | const char *summary; |
| 73 | struct bench *benchmarks; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 74 | }; |
| 75 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 76 | static struct collection collections[] = { |
Davidlohr Bueso | a043971 | 2013-12-14 20:31:55 -0800 | [diff] [blame] | 77 | { "sched", "Scheduler and IPC benchmarks", sched_benchmarks }, |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 78 | { "mem", "Memory access benchmarks", mem_benchmarks }, |
Ingo Molnar | 89fe808 | 2013-09-30 12:07:11 +0200 | [diff] [blame] | 79 | #ifdef HAVE_LIBNUMA_SUPPORT |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 80 | { "numa", "NUMA scheduling and MM benchmarks", numa_benchmarks }, |
Peter Hurley | 79d824e | 2013-01-27 20:51:22 -0500 | [diff] [blame] | 81 | #endif |
Davidlohr Bueso | a043971 | 2013-12-14 20:31:55 -0800 | [diff] [blame] | 82 | {"futex", "Futex stressing benchmarks", futex_benchmarks }, |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 83 | { "all", "All benchmarks", NULL }, |
| 84 | { NULL, NULL, NULL } |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 85 | }; |
| 86 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 87 | /* Iterate over all benchmark collections: */ |
| 88 | #define for_each_collection(coll) \ |
| 89 | for (coll = collections; coll->name; coll++) |
| 90 | |
| 91 | /* Iterate over all benchmarks within a collection: */ |
| 92 | #define for_each_bench(coll, bench) \ |
Patrick Palka | 6eeefcc | 2014-03-12 18:40:51 -0400 | [diff] [blame] | 93 | for (bench = coll->benchmarks; bench && bench->name; bench++) |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 94 | |
| 95 | static void dump_benchmarks(struct collection *coll) |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 96 | { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 97 | struct bench *bench; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 98 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 99 | printf("\n # List of available benchmarks for collection '%s':\n\n", coll->name); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 100 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 101 | for_each_bench(coll, bench) |
| 102 | printf("%14s: %s\n", bench->name, bench->summary); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 103 | |
| 104 | printf("\n"); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 105 | } |
| 106 | |
Arnaldo Carvalho de Melo | edb7c60 | 2010-05-17 16:22:41 -0300 | [diff] [blame] | 107 | static const char *bench_format_str; |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 108 | |
| 109 | /* Output/formatting style, exported to benchmark modules: */ |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 110 | int bench_format = BENCH_FORMAT_DEFAULT; |
Davidlohr Bueso | b6f0629 | 2014-06-16 11:14:19 -0700 | [diff] [blame] | 111 | unsigned int bench_repeat = 10; /* default number of times to repeat the run */ |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 112 | |
| 113 | static const struct option bench_options[] = { |
Ingo Molnar | 7a46a8f | 2015-10-19 10:04:22 +0200 | [diff] [blame] | 114 | OPT_STRING('f', "format", &bench_format_str, "default|simple", "Specify the output formatting style"), |
Davidlohr Bueso | b6f0629 | 2014-06-16 11:14:19 -0700 | [diff] [blame] | 115 | OPT_UINTEGER('r', "repeat", &bench_repeat, "Specify amount of times to repeat the run"), |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 116 | OPT_END() |
| 117 | }; |
| 118 | |
| 119 | static const char * const bench_usage[] = { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 120 | "perf bench [<common options>] <collection> <benchmark> [<options>]", |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 121 | NULL |
| 122 | }; |
| 123 | |
| 124 | static void print_usage(void) |
| 125 | { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 126 | struct collection *coll; |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 127 | int i; |
| 128 | |
| 129 | printf("Usage: \n"); |
| 130 | for (i = 0; bench_usage[i]; i++) |
| 131 | printf("\t%s\n", bench_usage[i]); |
| 132 | printf("\n"); |
| 133 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 134 | printf(" # List of all available benchmark collections:\n\n"); |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 135 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 136 | for_each_collection(coll) |
| 137 | printf("%14s: %s\n", coll->name, coll->summary); |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 138 | printf("\n"); |
| 139 | } |
| 140 | |
Arnaldo Carvalho de Melo | edb7c60 | 2010-05-17 16:22:41 -0300 | [diff] [blame] | 141 | static int bench_str2int(const char *str) |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 142 | { |
| 143 | if (!str) |
| 144 | return BENCH_FORMAT_DEFAULT; |
| 145 | |
| 146 | if (!strcmp(str, BENCH_FORMAT_DEFAULT_STR)) |
| 147 | return BENCH_FORMAT_DEFAULT; |
| 148 | else if (!strcmp(str, BENCH_FORMAT_SIMPLE_STR)) |
| 149 | return BENCH_FORMAT_SIMPLE; |
| 150 | |
| 151 | return BENCH_FORMAT_UNKNOWN; |
| 152 | } |
| 153 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 154 | /* |
| 155 | * Run a specific benchmark but first rename the running task's ->comm[] |
| 156 | * to something meaningful: |
| 157 | */ |
| 158 | static int run_bench(const char *coll_name, const char *bench_name, bench_fn_t fn, |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 159 | int argc, const char **argv) |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 160 | { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 161 | int size; |
| 162 | char *name; |
| 163 | int ret; |
| 164 | |
| 165 | size = strlen(coll_name) + 1 + strlen(bench_name) + 1; |
| 166 | |
| 167 | name = zalloc(size); |
| 168 | BUG_ON(!name); |
| 169 | |
| 170 | scnprintf(name, size, "%s-%s", coll_name, bench_name); |
| 171 | |
| 172 | prctl(PR_SET_NAME, name); |
| 173 | argv[0] = name; |
| 174 | |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 175 | ret = fn(argc, argv); |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 176 | |
| 177 | free(name); |
| 178 | |
| 179 | return ret; |
| 180 | } |
| 181 | |
| 182 | static void run_collection(struct collection *coll) |
| 183 | { |
| 184 | struct bench *bench; |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 185 | const char *argv[2]; |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 186 | |
| 187 | argv[1] = NULL; |
| 188 | /* |
| 189 | * TODO: |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 190 | * |
| 191 | * Preparing preset parameters for |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 192 | * embedded, ordinary PC, HPC, etc... |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 193 | * would be helpful. |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 194 | */ |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 195 | for_each_bench(coll, bench) { |
| 196 | if (!bench->fn) |
| 197 | break; |
| 198 | printf("# Running %s/%s benchmark...\n", coll->name, bench->name); |
Namhyung Kim | 9b494ea | 2013-01-08 18:39:26 +0900 | [diff] [blame] | 199 | fflush(stdout); |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 200 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 201 | argv[1] = bench->name; |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 202 | run_bench(coll->name, bench->name, bench->fn, 1, argv); |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 203 | printf("\n"); |
| 204 | } |
| 205 | } |
| 206 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 207 | static void run_all_collections(void) |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 208 | { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 209 | struct collection *coll; |
| 210 | |
| 211 | for_each_collection(coll) |
| 212 | run_collection(coll); |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 213 | } |
| 214 | |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 215 | int cmd_bench(int argc, const char **argv) |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 216 | { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 217 | struct collection *coll; |
| 218 | int ret = 0; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 219 | |
| 220 | if (argc < 2) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 221 | /* No collection specified. */ |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 222 | print_usage(); |
| 223 | goto end; |
| 224 | } |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 225 | |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 226 | argc = parse_options(argc, argv, bench_options, bench_usage, |
| 227 | PARSE_OPT_STOP_AT_NON_OPTION); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 228 | |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 229 | bench_format = bench_str2int(bench_format_str); |
| 230 | if (bench_format == BENCH_FORMAT_UNKNOWN) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 231 | printf("Unknown format descriptor: '%s'\n", bench_format_str); |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 232 | goto end; |
| 233 | } |
| 234 | |
Davidlohr Bueso | b6f0629 | 2014-06-16 11:14:19 -0700 | [diff] [blame] | 235 | if (bench_repeat == 0) { |
| 236 | printf("Invalid repeat option: Must specify a positive value\n"); |
| 237 | goto end; |
| 238 | } |
| 239 | |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 240 | if (argc < 1) { |
| 241 | print_usage(); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 242 | goto end; |
| 243 | } |
| 244 | |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 245 | if (!strcmp(argv[0], "all")) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 246 | run_all_collections(); |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 247 | goto end; |
| 248 | } |
| 249 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 250 | for_each_collection(coll) { |
| 251 | struct bench *bench; |
| 252 | |
| 253 | if (strcmp(coll->name, argv[0])) |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 254 | continue; |
| 255 | |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 256 | if (argc < 2) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 257 | /* No bench specified. */ |
| 258 | dump_benchmarks(coll); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 259 | goto end; |
| 260 | } |
| 261 | |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 262 | if (!strcmp(argv[1], "all")) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 263 | run_collection(coll); |
Hitoshi Mitake | 2044279 | 2009-12-13 17:01:59 +0900 | [diff] [blame] | 264 | goto end; |
| 265 | } |
| 266 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 267 | for_each_bench(coll, bench) { |
| 268 | if (strcmp(bench->name, argv[1])) |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 269 | continue; |
| 270 | |
Hitoshi Mitake | 79e295d | 2009-11-11 00:04:00 +0900 | [diff] [blame] | 271 | if (bench_format == BENCH_FORMAT_DEFAULT) |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 272 | printf("# Running '%s/%s' benchmark:\n", coll->name, bench->name); |
Namhyung Kim | 9b494ea | 2013-01-08 18:39:26 +0900 | [diff] [blame] | 273 | fflush(stdout); |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 274 | ret = run_bench(coll->name, bench->name, bench->fn, argc-1, argv+1); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 275 | goto end; |
| 276 | } |
| 277 | |
Hitoshi Mitake | 386d7e9 | 2009-11-10 08:20:00 +0900 | [diff] [blame] | 278 | if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 279 | dump_benchmarks(coll); |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 280 | goto end; |
| 281 | } |
| 282 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 283 | printf("Unknown benchmark: '%s' for collection '%s'\n", argv[1], argv[0]); |
| 284 | ret = 1; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 285 | goto end; |
| 286 | } |
| 287 | |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 288 | printf("Unknown collection: '%s'\n", argv[0]); |
| 289 | ret = 1; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 290 | |
| 291 | end: |
Ingo Molnar | 4157922 | 2013-10-23 14:37:56 +0200 | [diff] [blame] | 292 | return ret; |
Hitoshi Mitake | 629cc35 | 2009-11-05 09:31:34 +0900 | [diff] [blame] | 293 | } |