diff --git a/linux/libdoble_complete.a b/linux/libdoble_complete.a index abe0782..5acef16 100644 Binary files a/linux/libdoble_complete.a and b/linux/libdoble_complete.a differ diff --git a/macos-arm64/libdoble_complete.a b/macos-arm64/libdoble_complete.a index 898102a..82caf26 100644 Binary files a/macos-arm64/libdoble_complete.a and b/macos-arm64/libdoble_complete.a differ diff --git a/macos-x86_64/libdoble_complete.a b/macos-x86_64/libdoble_complete.a index 9428aff..65aa2f1 100644 Binary files a/macos-x86_64/libdoble_complete.a and b/macos-x86_64/libdoble_complete.a differ diff --git a/timer.c b/timer.c index 5228826..fd8f6c1 100644 --- a/timer.c +++ b/timer.c @@ -1,6 +1,37 @@ -#include #include "timer.h" +#if __APPLE__ +#include +static struct timespec start = {0, 0}; + +// Starts the timer. +void startTimer() +{ + clock_gettime(CLOCK_MONOTONIC, &start); +} + +// Returns the time in seconds since startTimer() was called. +double stopTimer() +{ + struct timespec end; + + clock_gettime(CLOCK_MONOTONIC, &end); + + unsigned long long delta_us = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000; + + double measuredSeconds = (double)delta_us / 1000000.; + + if(start.tv_nsec > 0) { + start.tv_nsec = 0; + start.tv_sec = 0; + } + else + measuredSeconds = -1; + + return measuredSeconds; +} +#else +#include static clock_t startClocks = 0; // Starts the timer. @@ -18,6 +49,7 @@ double stopTimer() startClocks = 0; else measuredSeconds = -1; - + return measuredSeconds; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/windows/libdoble_complete.a b/windows/libdoble_complete.a index ce72eb5..728bb8f 100644 Binary files a/windows/libdoble_complete.a and b/windows/libdoble_complete.a differ