PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms 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
 8using namespace std;
 9using namespace cln;
10
11int main (int argc, char * argv[])
12{
13	int limit = 1000;
14	int repetitions = 1;
15	while (argc >= 3) {
16		if (!strcmp(argv[1],"-r")) {
17			repetitions = atoi(argv[2]);
18			argc -= 2; argv += 2;
19			continue;
20		}
21		if (!strcmp(argv[1],"-l")) {
22			limit = atoi(argv[2]);
23			argc -= 2; argv += 2;
24			continue;
25		}
26		break;
27	}
28	if (argc < 1)
29		exit(1);
30
31	cerr << "Limit: " << limit << endl;
32	cerr << "Number of repetitions: " << repetitions << endl;
33
34	{ CL_TIMING;
35	  for (int rep = repetitions; rep > 0; rep--)
36	    { cl_I u = 1, v = 1, p = 1, q = 1;
37	      for (int k = 1; k <= limit; k++)
38	        { cl_I w = u+v;
39	          u = v; v = w;
40	          p = p*w; q = lcm(q,w);
41	        }
42	    }
43	}
44
45}