18 #include <mach/clock.h> 19 #include <mach/mach.h> 21 #include "./logging.h" 29 return std::chrono::duration<double>(
30 std::chrono::high_resolution_clock::now().time_since_epoch()).count();
31 #elif defined __MACH__ 34 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
35 CHECK(clock_get_time(cclock, &mts) == 0) <<
"failed to get time";
36 mach_port_deallocate(mach_task_self(), cclock);
37 return static_cast<double>(mts.tv_sec) + static_cast<double>(mts.tv_nsec) * 1e-9;
39 #if defined(__unix__) || defined(__linux__) 41 CHECK(clock_gettime(CLOCK_REALTIME, &ts) == 0) <<
"failed to get time";
42 return static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9;
44 return static_cast<double>(time(NULL));
49 #endif // DMLC_TIMER_H_ namespace for dmlc
Definition: array_view.h:12
double GetTime(void)
return time in seconds
Definition: timer.h:27