]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/src/timer.c
36fbedd48952e02e0088b22a9ca1d7101d36f2e7
1 #include "test/jemalloc_test.h"
4 timer_start(timedelta_t
*timer
)
7 gettimeofday(&timer
->tv0
, NULL
);
11 timer_stop(timedelta_t
*timer
)
14 gettimeofday(&timer
->tv1
, NULL
);
18 timer_usec(const timedelta_t
*timer
)
21 return (((timer
->tv1
.tv_sec
- timer
->tv0
.tv_sec
) * 1000000) +
22 timer
->tv1
.tv_usec
- timer
->tv0
.tv_usec
);
26 timer_ratio(timedelta_t
*a
, timedelta_t
*b
, char *buf
, size_t buflen
)
28 uint64_t t0
= timer_usec(a
);
29 uint64_t t1
= timer_usec(b
);
36 n
= malloc_snprintf(&buf
[i
], buflen
-i
, "%"PRIu64
, t0
/ t1
);
41 for (j
= 0; j
< n
; j
++)
45 n
= malloc_snprintf(&buf
[i
], buflen
-i
, ".");
49 while (i
< buflen
-1) {
50 uint64_t round
= (i
+1 == buflen
-1 && ((t0
* mult
* 10 / t1
) % 10
52 n
= malloc_snprintf(&buf
[i
], buflen
-i
,
53 "%"PRIu64
, (t0
* mult
/ t1
) % 10 + round
);