28ca7be add linear readme ca4b20f add linear readme 1133628 add linear readme 6a11676 update docs a607047 Update build.sh 2c1cfd8 complete yarn 4f28e32 change formater 2fbda81 fix stdin input 3258bcf checkin yarn master 67ebf81 allow setup from env variables 9b6bf57 fix hdfs 395d5c2 add make system 88ce767 refactor io, initial hdfs file access need test 19be870 chgs a1bd3c6 Merge branch 'master' of ssh://github.com/tqchen/rabit 1a573f9 introduce input split 29476f1 fix timer issue git-subtree-dir: subtree/rabit git-subtree-split: 28ca7becbdf6503e6b1398588a969efb164c9701
37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
/*!
|
|
* \file timer.h
|
|
* \brief This file defines the utils for timing
|
|
* \author Tianqi Chen, Nacho, Tianyi
|
|
*/
|
|
#ifndef RABIT_TIMER_H_
|
|
#define RABIT_TIMER_H_
|
|
#include <time.h>
|
|
#ifdef __MACH__
|
|
#include <mach/clock.h>
|
|
#include <mach/mach.h>
|
|
#endif
|
|
#include "./utils.h"
|
|
|
|
namespace rabit {
|
|
namespace utils {
|
|
/*!
|
|
* \brief return time in seconds, not cross platform, avoid to use this in most places
|
|
*/
|
|
inline double GetTime(void) {
|
|
#ifdef __MACH__
|
|
clock_serv_t cclock;
|
|
mach_timespec_t mts;
|
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
|
utils::Check(clock_get_time(cclock, &mts) == 0, "failed to get time");
|
|
mach_port_deallocate(mach_task_self(), cclock);
|
|
return static_cast<double>(mts.tv_sec) + static_cast<double>(mts.tv_nsec) * 1e-9;
|
|
#else
|
|
timespec ts;
|
|
utils::Check(clock_gettime(CLOCK_REALTIME, &ts) == 0, "failed to get time");
|
|
return static_cast<double>(ts.tv_sec) + static_cast<double>(ts.tv_nsec) * 1e-9;
|
|
#endif
|
|
}
|
|
} // namespace utils
|
|
} // namespace rabit
|
|
#endif // RABIT_TIMER_H_
|