3 #include <polylib/polylibgmp.h>
4 #include <barvinok/util.h>
5 #include <barvinok/barvinok.h>
7 #ifdef HAVE_SYS_TIMES_H
11 static void time_diff(struct tms
*before
, struct tms
*after
)
13 long ticks
= sysconf(_SC_CLK_TCK
);
14 printf("User: %g; Sys: %g\n",
15 (0.0 + after
->tms_utime
- before
->tms_utime
) / ticks
,
16 (0.0 + after
->tms_stime
- before
->tms_stime
) / ticks
);
22 static void times(struct tms
* time
)
25 static void time_diff(struct tms
*before
, struct tms
*after
)
33 static const int size
= 1000;
34 static const int loop
= 10;
39 struct tms tms_before
, tms_between
, tms_after
;
43 for (d
= 2; d
< 10; ++d
) {
44 M
= Matrix_Alloc(2*d
, 2+d
);
45 for (r
= 0; r
< 2*d
; ++r
)
46 value_set_si(M
->p
[r
][0], 1);
47 for (i
= 0; i
< loop
; ++i
) {
48 for (r
= 0; r
< 2*d
; ++r
) {
49 for (c
= 1; c
< 1+d
; ++c
) {
50 value_set_si(M
->p
[r
][c
], random_int(size
));
52 value_set_si(M
->p
[r
][d
+1], random_int(2)+1);
54 P
= Rays2Polyhedron(M
, 2*d
);
55 Polyhedron_Print(stdout
, P_VALUE_FMT
, P
);
59 barvinok_count(P
, &cb
, 100);
62 value_print(stdout
, P_VALUE_FMT
, cm
);
64 time_diff(&tms_before
, &tms_between
);
66 value_print(stdout
, P_VALUE_FMT
, cb
);
68 time_diff(&tms_between
, &tms_after
);
69 assert(value_eq(cm
, cb
));