7 #include <mach/clock.h>
10 #endif // ifndef _WIN32
15 typedef unsigned long time_type;
17 inline time_type get_time()
19 #ifdef __MACH__ // OS X does not have clock_gettime, use clock_get_time
22 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
23 clock_get_time(cclock, &ts);
24 mach_port_deallocate(mach_task_self(), cclock);
25 return ts.tv_sec*1000 +
static_cast<unsigned int>(ts.tv_nsec/1000000);
29 GetSystemTimeAsFileTime((FILETIME*)&wintime);
30 wintime -=116444736000000000i64;
31 long tv_sec =
static_cast<long>(wintime / 10000000i64);
32 long tv_nsec =
static_cast<long>(wintime % 10000000i64 *100);
33 return static_cast<time_type
>(tv_sec*1000 + tv_nsec/1000000);
36 clock_gettime(CLOCK_REALTIME, &ts);
37 return ts.tv_sec*1000 + ts.tv_nsec/1000000;