ddlog_bench.c 825 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <assert.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <strings.h>
  5. #include "ddlog.h"
  6. #include "entropy.h"
  7. #include "group.h"
  8. #include "timeit.h"
  9. int main()
  10. {
  11. group_init();
  12. dlog_precompute();
  13. mpz_entropy_init();
  14. INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
  15. for (int i=0; i < (int) (1e9 / (0x01 << strip_size) * 3.5); i++) {
  16. mpz_t n, n0;
  17. mpz_inits(n, n0, NULL);
  18. mpz_urandomm(n0, _rstate, p);
  19. mpz_set(n, n0);
  20. START_TIMEIT();
  21. #ifndef NDEBUG
  22. uint32_t converted =
  23. #endif
  24. convert(n->_mp_d);
  25. END_TIMEIT();
  26. mpz_set(n, n0);
  27. #ifndef NDEBUG
  28. uint32_t expected = naif_convert(n);
  29. printf("%d %d\n", converted, expected);
  30. assert(converted == expected);
  31. #endif
  32. mpz_clears(n, n0, NULL);
  33. }
  34. printf(TIMEIT_FORMAT "\n", GET_TIMEIT());
  35. group_clear();
  36. return 0;
  37. }