diff options
| author | hunter@kvog.sh <hunter@kvog.sh> | 2026-03-02 18:53:11 -0600 |
|---|---|---|
| committer | hunter@kvog.sh <hunter@kvog.sh> | 2026-03-02 18:53:11 -0600 |
| commit | 4fb7c337caedc0ecae9b59afbc155ba540ce45df (patch) | |
| tree | d22e1c8b794433ae783dad43ddff080f6c081286 /yuvbench/kbench.h | |
| parent | bc9b8e5e18674127d4930b12ce8e64dbcace1689 (diff) | |
yuvbench: libyuv
Diffstat (limited to 'yuvbench/kbench.h')
| -rw-r--r-- | yuvbench/kbench.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/yuvbench/kbench.h b/yuvbench/kbench.h index c5d4149..42ec646 100644 --- a/yuvbench/kbench.h +++ b/yuvbench/kbench.h @@ -9,6 +9,10 @@ double KBenchElapsedTime(uintptr_t t0, uintptr_t t1); #ifdef KBENCH_IMPLEMENTATION +#ifdef __linux__ +#include <time.h> +#endif + uintptr_t KBenchTS(void) { uintptr_t result = 0; @@ -16,6 +20,12 @@ uintptr_t KBenchTS(void) #if defined(__APPLE__) && defined(__clang__) && defined(__aarch64__) __asm__ volatile("mrs %0, CNTVCT_EL0" : "=r"(result) :: "memory"); #endif + // linux: use clock_gettime +#if defined(__linux__) + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + result = (uintptr_t)ts.tv_sec * 1e9 + (uintptr_t)ts.tv_nsec; +#endif return result; } @@ -35,6 +45,10 @@ double KBenchElapsedTime(uintptr_t t0, uintptr_t t1) __asm__ volatile("mrs %0, CNTFRQ_EL0" : "=r"(cntfreq_el0) :: "memory"); val = (double)elapsed / (double)cntfreq_el0; #endif + // linux: use clock_gettime +#if defined(__linux__) && defined(__GNUC__) && defined(__amd64__) + val = (double)elapsed / 1e9; +#endif return val; } |