Skip to content

Commit

Permalink
fixup! wip simplify gettime
Browse files Browse the repository at this point in the history
  • Loading branch information
aklomp committed Jan 9, 2024
1 parent f033b6b commit 45ef09a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
21 changes: 15 additions & 6 deletions test/benchmark.c
Expand Up @@ -27,10 +27,6 @@
# include <mach/mach_time.h>
#endif

#if defined(_WIN32)
# include "gettime_win.c"
#endif

#include "../include/libbase64.h"
#include "codec_supported.h"

Expand Down Expand Up @@ -120,7 +116,7 @@ get_random_data (struct buffers *b, char **errmsg)
#ifdef __MACH__
typedef uint64_t base64_timespec;
static void
base64_gettime (base64_timespec * o_time)
base64_gettime (base64_timespec *o_time)
{
*o_time = mach_absolute_time();
}
Expand All @@ -134,10 +130,23 @@ timediff_sec (base64_timespec *start, base64_timespec *end)

return (float)((diff * tb.numer) / tb.denom) / 1e9f;
}
#elif defined(_WIN32) && !(defined(__MINGW32__) || defined(__MINGW64__))
typedef struct timespec base64_timespec;
static void
base64_gettime (base64_timespec *o_time)
{
timespec_get(o_time, TIME_UTC);
}

static float
timediff_sec (base64_timespec *start, base64_timespec *end)
{
return (end->tv_sec - start->tv_sec) + ((float)(end->tv_nsec - start->tv_nsec)) / 1e9f;
}
#else
typedef struct timespec base64_timespec;
static void
base64_gettime (base64_timespec * o_time)
base64_gettime (base64_timespec *o_time)
{
clock_gettime(CLOCK_REALTIME, o_time);
}
Expand Down
9 changes: 0 additions & 9 deletions test/gettime_win.c

This file was deleted.

0 comments on commit 45ef09a

Please sign in to comment.