brstack.c 751 B

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