From 9b94c7d039341afb8609075da0ce52a7a7aa705a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 13 Aug 2025 16:38:21 +0100 Subject: More build.bat options --- tools/tool.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'tools/tool.h') diff --git a/tools/tool.h b/tools/tool.h index 47155c2..c6fafbc 100644 --- a/tools/tool.h +++ b/tools/tool.h @@ -22,6 +22,40 @@ log_stderr(const char *str, void *unused) fprintf(stderr, "%s", str); } +#ifdef _WIN32 + +#include + +static double +timerun(void (*run)(void)) +{ + LARGE_INTEGER freq, start, end; + double tdiff; + + fflush(stdout); + + if (run == NULL) { + printf("nothing to run!\n"); + fflush(stdout); + return -1.0; + } + + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&start); + run(); + QueryPerformanceCounter(&end); + + tdiff = (double)(end.QuadPart - start.QuadPart) / freq.QuadPart; + + printf("---------\n"); + printf("\nTotal time: %.4fs\n", tdiff); + fflush(stdout); + + return tdiff; +} + +#else + static double timerun(void (*run)(void)) { @@ -51,6 +85,8 @@ timerun(void (*run)(void)) return tdiff; } +#endif + static void writetable(const unsigned char *buf, int64_t size, const char *filename) { -- cgit v1.3