Tor  0.4.7.0-alpha-dev
bench-wheel.c
1 #include <stdlib.h>
2 
3 #define TIMEOUT_PUBLIC static
4 
5 #include "timeout.h"
6 #include "timeout.c"
7 #include "bench.h"
8 
9 
10 static void *init(struct timeout *timeout, size_t count, int verbose) {
11  struct timeouts *T;
12  size_t i;
13  int error;
14 
15  T = timeouts_open(TIMEOUT_mHZ, &error);
16 
17  for (i = 0; i < count; i++) {
18  timeout_init(&timeout[i], 0);
19  }
20 
21 #if TIMEOUT_DEBUG - 0
22  timeout_debug = verbose;
23 #endif
24 
25  return T;
26 } /* init() */
27 
28 
29 static void add(void *T, struct timeout *to, timeout_t expires) {
30  timeouts_add(T, to, expires);
31 } /* add() */
32 
33 
34 static void del(void *T, struct timeout *to) {
35  timeouts_del(T, to);
36 } /* del() */
37 
38 
39 static struct timeout *get(void *T) {
40  return timeouts_get(T);
41 } /* get() */
42 
43 
44 static void update(void *T, timeout_t ts) {
45  timeouts_update(T, ts);
46 } /* update() */
47 
48 
49 static void (check)(void *T) {
50  if (!timeouts_check(T, stderr))
51  _Exit(1);
52 } /* check() */
53 
54 
55 static int empty(void *T) {
56  return !(timeouts_pending(T) || timeouts_expired(T));
57 } /* empty() */
58 
59 
60 static struct timeout *next(void *T, struct timeouts_it *it) {
61  return timeouts_next(T, it);
62 } /* next() */
63 
64 
65 static void destroy(void *T) {
66  timeouts_close(T);
67 } /* destroy() */
68 
69 
70 const struct benchops benchops = {
71  .init = &init,
72  .add = &add,
73  .del = &del,
74  .get = &get,
75  .update = &update,
76  .check = &check,
77  .empty = &empty,
78  .next = &next,
79  .destroy = &destroy
80 };
81 
#define T(s, t, a, o)
Definition: parsecommon.h:245
Definition: bench.h:1