]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/src/timer.c
1 #include "test/jemalloc_test.h"
4 timer_start(timedelta_t
*timer
)
7 nstime_init(&timer
->t0
, 0);
8 nstime_update(&timer
->t0
);
12 timer_stop(timedelta_t
*timer
)
15 nstime_copy(&timer
->t1
, &timer
->t0
);
16 nstime_update(&timer
->t1
);
20 timer_usec(const timedelta_t
*timer
)
24 nstime_copy(&delta
, &timer
->t1
);
25 nstime_subtract(&delta
, &timer
->t0
);
26 return (nstime_ns(&delta
) / 1000);
30 timer_ratio(timedelta_t
*a
, timedelta_t
*b
, char *buf
, size_t buflen
)
32 uint64_t t0
= timer_usec(a
);
33 uint64_t t1
= timer_usec(b
);
40 n
= malloc_snprintf(&buf
[i
], buflen
-i
, "%"FMTu64
, t0
/ t1
);
45 for (j
= 0; j
< n
; j
++)
49 n
= malloc_snprintf(&buf
[i
], buflen
-i
, ".");
53 while (i
< buflen
-1) {
54 uint64_t round
= (i
+1 == buflen
-1 && ((t0
* mult
* 10 / t1
) % 10
56 n
= malloc_snprintf(&buf
[i
], buflen
-i
,
57 "%"FMTu64
, (t0
* mult
/ t1
) % 10 + round
);