summaryrefslogtreecommitdiff
path: root/source/test/unittests/foo.bench.c
blob: ac1e0b5e637e1be14a85d5bd94ecc3897edeab4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#define KIT_TEST_FILE foo
#include "../../kit_test/bench.h"

struct test_foo_ {
  double f;
};

BENCHMARK("foo") {

  /*  Benchmark setup.
   */

  BENCHMARK_BEGIN;
  {
    /*  Measured code snippet.
     */

    int              x = 0;
    struct test_foo_ f = { 0. };

    for (int i = 0; i < 100000; i++) {
      x += (1 << 1);
      x ^= i;
      f.f += 0.1;
    }

    DO_NOT_OPTIMIZE(x);
    DO_NOT_OPTIMIZE(f);
  }
  BENCHMARK_END;
}

BENCHMARK("bar") {
  BENCHMARK_REPEAT(10);
  BENCHMARK_REPEAT(100);

  BENCHMARK_BEGIN;
  BENCHMARK_END;
}

BENCHMARK("empty") { }