| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #include <stdlib.h> |
| 3 | #include "../tests.h" |
| 4 | |
| 5 | #define BENCH_RUNS 999999 |
| 6 | |
| 7 | static volatile int cnt; |
| 8 | |
| 9 | static void brstack_bar(void) { |
| 10 | } /* return */ |
| 11 | |
| 12 | static void brstack_foo(void) { |
| 13 | brstack_bar(); /* call */ |
| 14 | } /* return */ |
| 15 | |
| 16 | static void brstack_bench(void) { |
| 17 | void (*brstack_foo_ind)(void) = brstack_foo; |
| 18 | |
| 19 | if ((cnt++) % 3) /* branch (cond) */ |
| 20 | brstack_foo(); /* call */ |
| 21 | brstack_bar(); /* call */ |
| 22 | brstack_foo_ind(); /* call (ind) */ |
| 23 | } |
| 24 | |
| 25 | static int brstack(int argc, const char **argv) |
| 26 | { |
| 27 | int num_loops = BENCH_RUNS; |
| 28 | |
| 29 | if (argc > 0) |
| 30 | num_loops = atoi(argv[0]); |
| 31 | |
| 32 | while (1) { |
| 33 | if ((cnt++) > num_loops) |
| 34 | break; |
| 35 | brstack_bench();/* call */ |
| 36 | } /* branch (uncond) */ |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | DEFINE_WORKLOAD(brstack); |
| 41 | |