master
Alessandro Mauri 2 years ago
parent 1a552f8804
commit 09fe22e984
Signed by: alema
GPG Key ID: 2B7BF9531FF03BE8
  1. 2
      text_rendering/generic_hash.h
  2. 16
      text_rendering/util.c
  3. 3
      text_rendering/util.h

@ -123,7 +123,7 @@ struct htname##_entry * htname##_insert(struct htname##_ref *ht, struct htname##
} \ } \
\ \
\ \
struct htname##_ref * htname##_remove(struct htname##_ref *ht, codetype code) \ struct htname##_entry * htname##_remove(struct htname##_ref *ht, codetype code)\
{ \ { \
if (!ht) return NULL; \ if (!ht) return NULL; \
struct htname##_entry *r = htname##_search(ht, code); \ struct htname##_entry *r = htname##_search(ht, code); \

@ -8,6 +8,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <err.h> #include <err.h>
#include <time.h>
#include "util.h" #include "util.h"
@ -108,3 +109,18 @@ void print_byte(unsigned char byte)
{ {
printf("%s%s", bit_rep[byte >> 4], bit_rep[byte & 0x0F]); printf("%s%s", bit_rep[byte >> 4], bit_rep[byte & 0x0F]);
} }
static struct timespec clock_start, clock_stop;
void stopwatch_start(void)
{
clock_gettime(CLOCK_MONOTONIC_COARSE, &clock_start);
}
double stopwatch_get(void)
{
clock_gettime(CLOCK_MONOTONIC_COARSE, &clock_stop);
return (clock_stop.tv_sec-clock_start.tv_sec)+(double)(clock_stop.tv_nsec-clock_start.tv_nsec)/(double)1000000000L;
}

@ -15,4 +15,7 @@ void dump_file(const char *path, char **buf, int *buf_len);
void print_byte(unsigned char byte); void print_byte(unsigned char byte);
void stopwatch_start(void);
double stopwatch_get(void);
#endif #endif

Loading…
Cancel
Save