PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/benchmarks/timebench2ap.cc

#
C++ | 45 lines | 40 code | 5 blank | 0 comment | 6 complexity | 256bf2a3bc9930e82386c27f17abb600 MD5 | raw file
Possible License(s): GPL-2.0
  1. #include <cln/number.h>
  2. #include <cln/io.h>
  3. #include <cln/integer.h>
  4. #include <cstdlib>
  5. #include <cstring>
  6. #include <cln/timing.h>
  7. using namespace std;
  8. using namespace cln;
  9. int main (int argc, char * argv[])
  10. {
  11. int limit = 1000;
  12. int repetitions = 1;
  13. while (argc >= 3) {
  14. if (!strcmp(argv[1],"-r")) {
  15. repetitions = atoi(argv[2]);
  16. argc -= 2; argv += 2;
  17. continue;
  18. }
  19. if (!strcmp(argv[1],"-l")) {
  20. limit = atoi(argv[2]);
  21. argc -= 2; argv += 2;
  22. continue;
  23. }
  24. break;
  25. }
  26. if (argc < 1)
  27. exit(1);
  28. cerr << "Limit: " << limit << endl;
  29. cerr << "Number of repetitions: " << repetitions << endl;
  30. { CL_TIMING;
  31. for (int rep = repetitions; rep > 0; rep--)
  32. { cl_I u = 1, v = 1, p = 1, q = 1;
  33. for (int k = 1; k <= limit; k++)
  34. { cl_I w = u+v;
  35. u = v; v = w;
  36. p = p*w; q = lcm(q,w);
  37. }
  38. }
  39. }
  40. }