]> www.ginac.de Git - cln.git/blob - tests/timepi.cc
benchmarks: time{catalan,euler,exp1,zeta3}.cc actually compile and work now.
[cln.git] / tests / timepi.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/float.h>
4 #include <cln/float_io.h>
5 #include <cln/real.h>
6 #include <cln/random.h>
7 #include <cstdlib>
8 #include <cstring>
9 #include <cln/timing.h>
10
11 using namespace std;
12 using namespace cln;
13
14 int main (int argc, char * argv[])
15 {
16         int repetitions = 1;
17         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
18                 repetitions = atoi(argv[2]);
19                 argc -= 2; argv += 2;
20         }
21         if (argc < 2)
22                 exit(1);
23 #if 0
24         uintL len = atoi(argv[1]);
25         extern cl_LF compute_pi_brent_salamin (uintC len);
26         extern cl_LF compute_pi_brent_salamin_quartic (uintC len);
27         extern cl_LF compute_pi_ramanujan_163 (uintC len);
28         extern cl_LF compute_pi_ramanujan_163_fast (uintC len);
29         cl_LF p;
30         { CL_TIMING;
31           for (int rep = repetitions; rep > 0; rep--)
32             { p = compute_pi_brent_salamin(len); }
33         }
34 //      cout << p << endl;
35         { CL_TIMING;
36           for (int rep = repetitions; rep > 0; rep--)
37             { p = compute_pi_brent_salamin_quartic(len); }
38         }
39 //      cout << p << endl;
40         { CL_TIMING;
41           for (int rep = repetitions; rep > 0; rep--)
42             { p = compute_pi_ramanujan_163(len); }
43         }
44 //      cout << p << endl;
45         { CL_TIMING;
46           for (int rep = repetitions; rep > 0; rep--)
47             { p = compute_pi_ramanujan_163_fast(len); }
48         }
49 //      cout << p << endl;
50 #else
51         // Here the argument is N *decimal* digits, not N*32 bits!
52         int n = atoi(argv[1]);
53         float_format_t prec = float_format(n);
54         cl_F p;
55         cerr << "Computing pi" << endl;
56         { CL_TIMING; p = pi(prec); }
57         cerr << "Converting pi to decimal" << endl;
58         { CL_TIMING; cout << p << endl << endl; }
59 #endif
60 }