blob: db8d922b6174af42a458cf2470496a82f110c9f2 (
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
43
44
45
46
47
48
|
#ifndef BH_BENCH_H
#define BH_BENCH_H
#include <BH/Common.h>
typedef struct BH_Bench BH_Bench;
typedef void (*BH_BenchCallback)(BH_Bench *);
#define BH_BENCH_TEST(name) \
static void bench##name(BH_Bench *state)
#define BH_BENCH_ADD(name) \
BH_BenchAdd(#name, bench##name)
void BH_BenchAdd(const char *name,
BH_BenchCallback cb);
int BH_BenchIter(BH_Bench *state);
void BH_BenchSubcount(BH_Bench *state,
size_t count);
int BH_BenchRun(void);
#if defined(__GNUC__) || defined(__clang__)
#define BH_BenchDoNotOptimize(arg) \
do { \
__asm__ __volatile__("" : : "r"(*((char volatile*) &arg)) : "memory"); \
} while (0)
#else
#define BH_BenchDoNotOptimize(arg) \
do { \
volatile void* _ptr = (void*)&(arg); \
(void)_ptr; \
} while (0)
#endif
#endif /* BH_BENCH_H */
|