You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

25 years ago
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/integer.h>
  4. #include <cln/random.h>
  5. #include <cstdlib>
  6. #include <cstring>
  7. #include <cln/timing.h>
  8. int main (int argc, char * argv[])
  9. {
  10. int repetitions = 1;
  11. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  12. repetitions = atoi(argv[2]);
  13. argc -= 2; argv += 2;
  14. }
  15. if (argc < 2)
  16. exit(1);
  17. cl_I m1 = cl_I(argv[1]);
  18. cl_I M1 = (cl_I)1 << (intDsize*m1);
  19. cl_I m2 = (argc>2 ? cl_I(argv[2]) : m1);
  20. cl_I M2 = (cl_I)1 << (intDsize*m2);
  21. cl_I a = random_I(M1);
  22. cl_I b = random_I(M2);
  23. extern int cl_mul_algo;
  24. cl_mul_algo = 0;
  25. { CL_TIMING;
  26. for (int rep = repetitions; rep > 0; rep--)
  27. { cl_I p = a * b; }
  28. }
  29. cl_mul_algo = 1;
  30. { CL_TIMING;
  31. for (int rep = repetitions; rep > 0; rep--)
  32. { cl_I p = a * b; }
  33. }
  34. cl_mul_algo = 2;
  35. { CL_TIMING;
  36. for (int rep = repetitions; rep > 0; rep--)
  37. { cl_I p = a * b; }
  38. }
  39. cl_mul_algo = 3;
  40. { CL_TIMING;
  41. for (int rep = repetitions; rep > 0; rep--)
  42. { cl_I p = a * b; }
  43. }
  44. cl_mul_algo = 4;
  45. { CL_TIMING;
  46. for (int rep = repetitions; rep > 0; rep--)
  47. { cl_I p = a * b; }
  48. }
  49. }