mul_bench.c 637 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <gmp.h>
  4. #include "entropy.h"
  5. #include "group.h"
  6. #include "timeit.h"
  7. int main()
  8. {
  9. mpz_entropy_init();
  10. group_init();
  11. mpz_t test, expected, x, y;
  12. mpz_inits(test, expected, x, y, NULL);
  13. printf("e6time\n");
  14. for (int n = 0; n < 0x01 << 16; n++) {
  15. INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
  16. for (int i = 0; i < (int) 1e6; i++) {
  17. mpz_urandomm(x, _rstate, p);
  18. mpz_urandomm(y, _rstate, p);
  19. START_TIMEIT();
  20. mul_modp(expected, x, y);
  21. END_TIMEIT();
  22. }
  23. printf(TIMEIT_FORMAT "\n", GET_TIMEIT());
  24. }
  25. mpz_clears(test, expected, x, y, NULL);
  26. }