]>
git.proxmox.com Git - ceph.git/blob - ceph/src/utf8proc/bench/util.c
7 /* read file named FILENAME into an array of *len bytes,
8 returning NULL on error */
9 uint8_t *readfile(const char *filename
, size_t *len
)
13 if (0 != stat(filename
, &st
)) return NULL
;
15 FILE *f
= fopen(filename
, "r");
17 uint8_t *s
= (uint8_t *) malloc(sizeof(uint8_t) * *len
);
19 if (fread(s
, 1, *len
, f
) != *len
) {
27 mytime
gettime(void) {
29 gettimeofday(&t
, NULL
);
33 /* time difference in seconds */
34 double elapsed(mytime t1
, mytime t0
)
36 return (double)(t1
.tv_sec
- t0
.tv_sec
) +
37 (double)(t1
.tv_usec
- t0
.tv_usec
) * 1.0E-6;