2016-09-05 19:47:26 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-05 19:47:26 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-06 16:44:05 +00:00
|
|
|
#ifndef _TIMER_H
|
|
|
|
#define _TIMER_H
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#define hc_timer_get(a,r) { hc_timer_t hr_freq; QueryPerformanceFrequency (&hr_freq); hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) ((double) (hr_tmp.QuadPart - (a).QuadPart) / (double) (hr_freq.QuadPart / 1000)); }
|
|
|
|
#define hc_timer_set(a) { QueryPerformanceCounter ((a)); }
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#elif defined (_POSIX)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#define hc_timer_get(a,r) { hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000)); }
|
|
|
|
#define hc_timer_set(a) { gettimeofday ((a), NULL); }
|
|
|
|
|
|
|
|
#endif
|
2016-09-06 16:44:05 +00:00
|
|
|
|
|
|
|
#endif // _TIMER_H
|