3 #include <barvinok/util.h>
4 #include <barvinok/barvinok.h>
6 #ifdef HAVE_SYS_TIMES_H
10 static void time_diff(struct tms
*before
, struct tms
*after
)
12 long ticks
= sysconf(_SC_CLK_TCK
);
13 printf("User: %g; Sys: %g\n",
14 (0.0 + after
->tms_utime
- before
->tms_utime
) / ticks
,
15 (0.0 + after
->tms_stime
- before
->tms_stime
) / ticks
);
21 static void times(struct tms
* time
)
24 static void time_diff(struct tms
*before
, struct tms
*after
)
32 static const int size
= 1000;
33 static const int loop
= 10;
38 struct tms tms_before
, tms_between
, tms_after
;
42 for (d
= 2; d
< 10; ++d
) {
43 M
= Matrix_Alloc(2*d
, 2+d
);
44 for (r
= 0; r
< 2*d
; ++r
)
45 value_set_si(M
->p
[r
][0], 1);
46 for (i
= 0; i
< loop
; ++i
) {
47 for (r
= 0; r
< 2*d
; ++r
) {
48 for (c
= 1; c
< 1+d
; ++c
) {
49 value_set_si(M
->p
[r
][c
], random_int(size
));
51 value_set_si(M
->p
[r
][d
+1], random_int(2)+1);
53 P
= Rays2Polyhedron(M
, 2*d
);
54 Polyhedron_Print(stdout
, P_VALUE_FMT
, P
);
58 barvinok_count(P
, &cb
, 100);
61 value_print(stdout
, P_VALUE_FMT
, cm
);
63 time_diff(&tms_before
, &tms_between
);
65 value_print(stdout
, P_VALUE_FMT
, cb
);
67 time_diff(&tms_between
, &tms_after
);
68 assert(value_eq(cm
, cb
));