aboutsummaryrefslogtreecommitdiff
path: root/src/ext/timeouts/bench/bench-wheel.c
blob: 0cba1af83ed1fa09c508f8f27fe2f31b3f512a01 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdlib.h>

#define TIMEOUT_PUBLIC static

#include "timeout.h"
#include "timeout.c"
#include "bench.h"


static void *init(struct timeout *timeout, size_t count, int verbose) {
	struct timeouts *T;
	size_t i;
	int error;

	T = timeouts_open(TIMEOUT_mHZ, &error);

	for (i = 0; i < count; i++) {
		timeout_init(&timeout[i], 0);
	}

#if TIMEOUT_DEBUG - 0
	timeout_debug = verbose;
#endif

	return T;
} /* init() */


static void add(void *T, struct timeout *to, timeout_t expires) {
	timeouts_add(T, to, expires);
} /* add() */


static void del(void *T, struct timeout *to) {
	timeouts_del(T, to);
} /* del() */


static struct timeout *get(void *T) {
	return timeouts_get(T);
} /* get() */


static void update(void *T, timeout_t ts) {
	timeouts_update(T, ts);
} /* update() */


static void (check)(void *T) {
	if (!timeouts_check(T, stderr))
		_Exit(1);
} /* check() */


static int empty(void *T) {
	return !(timeouts_pending(T) || timeouts_expired(T));
} /* empty() */


static struct timeout *next(void *T, struct timeouts_it *it) {
	return timeouts_next(T, it);
} /* next() */


static void destroy(void *T) {
	timeouts_close(T);
} /* destroy() */


const struct benchops benchops = {
	.init    = &init,
	.add     = &add,
	.del     = &del,
	.get     = &get,
	.update  = &update,
	.check   = &check,
	.empty   = &empty,
	.next    = &next,
	.destroy = &destroy
};