diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-09-30 10:55:55 +0200 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-09-30 10:55:55 +0200 |
commit | a06ff64534815cbf702a3847a19443612d307b80 (patch) | |
tree | 0b2023643f0d9d86296d4e4cbd9a683995d26230 /blossom5-v2.05.src/timer.h | |
parent | fc1f46cd4870476d77b5ab28799f47de242e3617 (diff) | |
download | code-a06ff64534815cbf702a3847a19443612d307b80.tar.gz code-a06ff64534815cbf702a3847a19443612d307b80.tar.bz2 code-a06ff64534815cbf702a3847a19443612d307b80.zip |
Changed rbmp to use blossom algorithm.
Diffstat (limited to 'blossom5-v2.05.src/timer.h')
-rw-r--r-- | blossom5-v2.05.src/timer.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/blossom5-v2.05.src/timer.h b/blossom5-v2.05.src/timer.h new file mode 100644 index 0000000..a0b9373 --- /dev/null +++ b/blossom5-v2.05.src/timer.h @@ -0,0 +1,98 @@ +#ifndef NJAKSDTHASKJERAXJGFBZJDLAGZ +#define NJAKSDTHASKJERAXJGFBZJDLAGZ + +// At most one of the flags +// PM_TIMER_MSVC +// PM_TIMER_CLOCK_GETTIME +// PM_TIMER_GETRUSAGE +// PM_TIMER_EXTERNAL +// PM_TIMER_NONE +// can be defined externally. If PM_TIMER_EXTERNAL is defined, +// then there must exist a definition of function "double get_time()" elsewhere. + +#if defined (PM_TIMER_MSVC) || defined (PM_TIMER_CLOCK_GETTIME) || defined (PM_TIMER_GETRUSAGE) || defined (PM_TIMER_EXTERNAL) || defined (PM_TIMER_NONE) +#else + // default option + #ifdef _MSC_VER + #define PM_TIMER_MSVC + #elif defined(__APPLE_CC__) + #define PM_TIMER_GETRUSAGE + #else + #define PM_TIMER_CLOCK_GETTIME + #endif +#endif + +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +#ifdef PM_TIMER_MSVC + + #include <windows.h> + + inline double get_time() + { + LARGE_INTEGER t, frequency; + QueryPerformanceCounter(&t); + QueryPerformanceFrequency(&frequency); + return (double)t.QuadPart/(double)frequency.QuadPart; + } + +#endif + +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +#ifdef PM_TIMER_CLOCK_GETTIME + + #include <time.h> + + inline double get_time() + { + struct timespec t; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t); + return (double)t.tv_nsec*1.00E-9 + (double)t.tv_sec; + } + +#endif + +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +#ifdef PM_TIMER_GETRUSAGE + + #include <sys/resource.h> + + inline double get_time() + { + struct rusage t; + getrusage (RUSAGE_SELF, &t); + return (double)t.ru_utime.tv_usec*1.00E-6 + (double)t.ru_utime.tv_sec; + } + +#endif + +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +#ifdef PM_TIMER_EXTERNAL + + extern double get_time(); + +#endif + +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// + +#ifdef PM_TIMER_NONE + + inline double get_time() { return 0; } + +#endif + +#endif + |