]> www.ginac.de Git - cln.git/blob - tests/timeprint.cc
Fix crashes in find_univpoly_ring and related functions
[cln.git] / tests / timeprint.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include <cln/integer_io.h>
5 #include <cln/random.h>
6 #include <cstdlib>
7 #include <cstring>
8 #include <cln/timing.h>
9 #include <cln/malloc.h>
10 #include <cln/abort.h>
11 using namespace cln;
12
13 int main (int argc, char * argv[])
14 {
15         int repetitions = 1;
16         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
17                 repetitions = atoi(argv[2]);
18                 argc -= 2; argv += 2;
19         }
20         if (argc < 2)
21                 exit(1);
22         cl_I m = cl_I(argv[1]);
23         cl_I M = (cl_I)1 << (intDsize*m);
24         cl_I a = random_I(M);
25         // One run to fill the cache.
26         {
27                 char* p = cl_decimal_string(a);
28                 free_hook(p);
29         }
30         // Now start the timing.
31         { CL_TIMING;
32           for (int rep = repetitions; rep > 0; rep--)
33             { char* p = cl_decimal_string(a); free_hook(p); }
34         }
35 }