]> www.ginac.de Git - cln.git/blob - tests/timeLFln-compare.cc
benchmarks: time{catalan,euler,exp1,zeta3}.cc actually compile and work now.
[cln.git] / tests / timeLFln-compare.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/float.h>
4 #include <cln/lfloat.h>
5 #include "float/lfloat/cl_LF.h"
6 #include <cln/real.h>
7 #include <cln/random.h>
8 #include <cstdlib>
9 #include <cstring>
10 #include <cln/timing.h>
11
12 int main (int argc, char * argv[])
13 {
14         int repetitions = 1;
15         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
16                 repetitions = atoi(argv[2]);
17                 argc -= 2; argv += 2;
18         }
19         if (argc < 2)
20                 exit(1);
21         uintL len = atoi(argv[1]);
22 #if 0
23         cl_LF one = cl_I_to_LF(1,len);
24         cl_F x = one + random_F(one)/3;
25         cout << x << endl;
26 #else
27         cl_F x = sqrt(sqrt(cl_I_to_LF(2,len)));
28 #endif
29         cl_F y;
30         extern int cl_lnx_algo;
31         cl_lnx_algo = 0;
32         y = ln(x); // fill cache
33         { CL_TIMING;
34           for (int rep = repetitions; rep > 0; rep--)
35             { y = ln(x); }
36         }
37         cout << y << endl;
38         cl_lnx_algo = 1;
39         { CL_TIMING;
40           for (int rep = repetitions; rep > 0; rep--)
41             { y = ln(x); }
42         }
43         cout << y << endl;
44 }