bench-wheel.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <stdlib.h>
  2. #define TIMEOUT_PUBLIC static
  3. #include "timeout.h"
  4. #include "timeout.c"
  5. #include "bench.h"
  6. static void *init(struct timeout *timeout, size_t count, int verbose) {
  7. struct timeouts *T;
  8. size_t i;
  9. int error;
  10. T = timeouts_open(TIMEOUT_mHZ, &error);
  11. for (i = 0; i < count; i++) {
  12. timeout_init(&timeout[i], 0);
  13. }
  14. #if TIMEOUT_DEBUG - 0
  15. timeout_debug = verbose;
  16. #endif
  17. return T;
  18. } /* init() */
  19. static void add(void *T, struct timeout *to, timeout_t expires) {
  20. timeouts_add(T, to, expires);
  21. } /* add() */
  22. static void del(void *T, struct timeout *to) {
  23. timeouts_del(T, to);
  24. } /* del() */
  25. static struct timeout *get(void *T) {
  26. return timeouts_get(T);
  27. } /* get() */
  28. static void update(void *T, timeout_t ts) {
  29. timeouts_update(T, ts);
  30. } /* update() */
  31. static void (check)(void *T) {
  32. if (!timeouts_check(T, stderr))
  33. _Exit(1);
  34. } /* check() */
  35. static int empty(void *T) {
  36. return !(timeouts_pending(T) || timeouts_expired(T));
  37. } /* empty() */
  38. static struct timeout *next(void *T, struct timeouts_it *it) {
  39. return timeouts_next(T, it);
  40. } /* next() */
  41. static void destroy(void *T) {
  42. timeouts_close(T);
  43. } /* destroy() */
  44. const struct benchops benchops = {
  45. .init = &init,
  46. .add = &add,
  47. .del = &del,
  48. .get = &get,
  49. .update = &update,
  50. .check = &check,
  51. .empty = &empty,
  52. .next = &next,
  53. .destroy = &destroy
  54. };