This commit is contained in:
Alessandro Mauri 2023-03-12 00:28:38 +01:00
parent 1a552f8804
commit 09fe22e984
Signed by: alema
GPG Key ID: 2B7BF9531FF03BE8
3 changed files with 20 additions and 1 deletions

View File

@ -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; \
struct htname##_entry *r = htname##_search(ht, code); \

View File

@ -8,6 +8,7 @@
#include <unistd.h>
#include <errno.h>
#include <err.h>
#include <time.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]);
}
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;
}

View File

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