blob: 011817d7bdd16d6e9b724596b39442faa43f0afa (
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
42
|
#define KIT_TEST_FILE bench
#include "../kit/test.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") { }
#undef KIT_TEST_FILE
|