]> www.ginac.de Git - cln.git/blob - tests/timeprint.cc
b8774aafe2d5d13870dfdc985fc8a6a1549d45cc
[cln.git] / tests / timeprint.cc
1 #include <cl_number.h>
2 #include <cl_io.h>
3 #include <cl_integer.h>
4 #include <cl_integer_io.h>
5 #include <cl_random.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <cl_timing.h>
9 #include <cl_malloc.h>
10 #include <cl_abort.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         cl_I m = cl_I(argv[1]);
22         cl_I M = (cl_I)1 << (intDsize*m);
23         cl_I a = random_I(M);
24         // One run to fill the cache.
25         {
26                 char* p = cl_decimal_string(a);
27                 cl_free_hook(p);
28         }
29         // Now start the timing.
30         { CL_TIMING;
31           for (int rep = repetitions; rep > 0; rep--)
32             { char* p = cl_decimal_string(a); cl_free_hook(p); }
33         }
34 }