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.

44 lines
1.0 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
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 <stdlib.h>
  6. #include <string.h>
  7. #include <cln/timing.h>
  8. #include <cl_print.h>
  9. #include <cln/malloc.h>
  10. #include <cln/abort.h>
  11. int main (int argc, char * argv[])
  12. {
  13. int repetitions = 1;
  14. if ((argc >= 3) && !strcmp(argv[1],"-r")) {
  15. repetitions = atoi(argv[2]);
  16. argc -= 2; argv += 2;
  17. }
  18. if (argc < 2)
  19. exit(1);
  20. cl_I m = cl_I(argv[1]);
  21. cl_I M = (cl_I)1 << (intDsize*m);
  22. cl_I a = random_I(M);
  23. extern int cl_digits_algo;
  24. // One run to fill the cache.
  25. {
  26. char* p = (cl_digits_algo = 0, cl_decimal_string(a));
  27. char* q = (cl_digits_algo = 1, cl_decimal_string(a));
  28. if (strcmp(p,q)) cl_abort();
  29. free_hook(p);
  30. free_hook(q);
  31. }
  32. // Now start the timing.
  33. cl_digits_algo = 0;
  34. { CL_TIMING;
  35. for (int rep = repetitions; rep > 0; rep--)
  36. { char* p = cl_decimal_string(a); free_hook(p); }
  37. }
  38. cl_digits_algo = 1;
  39. { CL_TIMING;
  40. for (int rep = repetitions; rep > 0; rep--)
  41. { char* p = cl_decimal_string(a); free_hook(p); }
  42. }
  43. }