Skip to content

Commit

Permalink
Fix timing in tester on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
binji committed Aug 16, 2023
1 parent 155d747 commit b217c94
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
#include <string.h>
#include <inttypes.h>

#ifndef _MSC_VER
#if defined(BINJNES_MSVC)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#undef ERROR
#else
#include <sys/time.h>
#endif

Expand Down Expand Up @@ -79,8 +84,11 @@ void usage(int argc, char** argv) {

static f64 get_time_sec(void) {
#ifdef _MSC_VER
// TODO(binji): Windows equivalent of gettimeofday.
return 0;
// https://stackoverflow.com/a/34833160
LARGE_INTEGER fq, t;
QueryPerformanceFrequency(&fq);
QueryPerformanceCounter(&t);
return (f64)(1000000 * t.QuadPart) / (fq.QuadPart * 1000000.0);
#else
struct timeval tp;
gettimeofday(&tp, NULL);
Expand Down

0 comments on commit b217c94

Please sign in to comment.