]> www.ginac.de Git - cln.git/blob - tests/timemul-compare.cc
* src/base/digitseq/cl_DS.h: #undef DS, needed for i386-Solaris.
[cln.git] / tests / timemul-compare.cc
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
9 int main (int argc, char * argv[])
10 {
11         int repetitions = 1;
12         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
13                 repetitions = atoi(argv[2]);
14                 argc -= 2; argv += 2;
15         }
16         if (argc < 2)
17                 exit(1);
18         cl_I m1 = cl_I(argv[1]);
19         cl_I M1 = (cl_I)1 << (intDsize*m1);
20         cl_I m2 = (argc>2 ? cl_I(argv[2]) : m1);
21         cl_I M2 = (cl_I)1 << (intDsize*m2);
22         cl_I a = random_I(M1);
23         cl_I b = random_I(M2);
24         extern int cl_mul_algo;
25         cl_mul_algo = 0;
26         { CL_TIMING;
27           for (int rep = repetitions; rep > 0; rep--)
28             { cl_I p = a * b; }
29         }
30         cl_mul_algo = 1;
31         { CL_TIMING;
32           for (int rep = repetitions; rep > 0; rep--)
33             { cl_I p = a * b; }
34         }
35         cl_mul_algo = 2;
36         { CL_TIMING;
37           for (int rep = repetitions; rep > 0; rep--)
38             { cl_I p = a * b; }
39         }
40         cl_mul_algo = 3;
41         { CL_TIMING;
42           for (int rep = repetitions; rep > 0; rep--)
43             { cl_I p = a * b; }
44         }
45         cl_mul_algo = 4;
46         { CL_TIMING;
47           for (int rep = repetitions; rep > 0; rep--)
48             { cl_I p = a * b; }
49         }
50 }