#ifndef SIGNALSMITH_STOPWATCH_UTIL_H #define SIGNALSMITH_STOPWATCH_UTIL_H #include #include #include #include // We want CPU time, not wall-clock time, so we can't use `std::chrono::high_resolution_clock` #ifdef WINDOWS # include namespace signalsmith { class Stopwatch { using Time = __int64; inline Time now() { LARGE_INTEGER result; QueryPerformanceCounter(&result); return result.QuadPart; } static double timeToSeconds(double t) { LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return t/double(freq); } #else # include namespace signalsmith { class Stopwatch { using Time = std::clock_t; inline Time now() { return std::clock(); } static double timeToSeconds(double t) { return t/double(CLOCKS_PER_SEC); } #endif std::atomic