Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

bench.c 1.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <assert.h>
  6. #include "u512.h"
  7. #include "fp.h"
  8. #include "mont.h"
  9. #include "csidh.h"
  10. #include <inttypes.h>
  11. static __inline__ uint64_t rdtsc(void)
  12. {
  13. uint32_t hi, lo;
  14. __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
  15. return lo | (uint64_t) hi << 32;
  16. }
  17. unsigned long its = 10000;
  18. int main()
  19. {
  20. clock_t t0, t1, time = 0;
  21. uint64_t c0, c1, cycles = 0;
  22. private_key priv;
  23. public_key pub = base;
  24. for (unsigned long i = 0; i < its; ++i) {
  25. csidh_private(&priv);
  26. t0 = clock();
  27. c0 = rdtsc();
  28. /**************************************/
  29. assert(validate(&pub));
  30. action(&pub, &pub, &priv);
  31. /**************************************/
  32. c1 = rdtsc();
  33. t1 = clock();
  34. cycles += c1 - c0;
  35. time += t1 - t0;
  36. }
  37. printf("iterations: %lu\n", its);
  38. printf("clock cycles: %" PRIu64 "\n", (uint64_t) cycles / its);
  39. printf("wall-clock time: %.3lf ms\n", 1000. * time / CLOCKS_PER_SEC / its);
  40. }