From 7e6c14a2f6e9e9cbac3431f3085c42bbe474d13d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 29 Aug 2024 15:51:33 +0200 Subject: Refactor tools to remove duplicate code --- tools/timerun.h | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 tools/timerun.h (limited to 'tools/timerun.h') diff --git a/tools/timerun.h b/tools/timerun.h deleted file mode 100644 index 58a8e7a..0000000 --- a/tools/timerun.h +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include -#include -#include -#include - -void -log_stderr(const char *str, ...) -{ - va_list args; - - va_start(args, str); - vfprintf(stderr, str, args); - va_end(args); -} - - -double -timerun(void (*run)(void), char *name) -{ - struct timespec start, end; - double tdiff, tdsec, tdnano; - - printf("\n"); - fflush(stdout); - - if (run == NULL) { - printf("> %s: nothing to run!\n", name); - fflush(stdout); - return -1.0; - } - - printf("Running tool: %s\n", name); - printf("==========\n"); - fflush(stdout); - - clock_gettime(CLOCK_MONOTONIC, &start); - run(); - clock_gettime(CLOCK_MONOTONIC, &end); - - tdsec = end.tv_sec - start.tv_sec; - tdnano = end.tv_nsec - start.tv_nsec; - tdiff = tdsec + 1e-9 * tdnano; - - printf("==========\n"); - printf("\nTotal time: %.4fs\n", tdiff); - fflush(stdout); - - return tdiff; -} -- cgit v1.3