unsigned long long SystemCall::getCurrentThreadTime() { #if defined(WINDOWS) static LARGE_INTEGER frequency = { 0 }; if (frequency.QuadPart == 0) { QueryPerformanceFrequency(&frequency); } LARGE_INTEGER timeLL; QueryPerformanceCounter(&timeLL); return static_cast<unsigned long long>(timeLL.QuadPart * 1000000 / frequency.QuadPart); #elif defined(OSX) // FIXME return (unsigned long long) getRealSystemTime() * 1000; #else clockid_t cid; struct timespec ts; VERIFY(pthread_getcpuclockid(pthread_self(), &cid) == 0); VERIFY(clock_gettime(cid, &ts) == 0); unsigned long long time = ts.tv_sec * 1000000ll + ts.tv_nsec / 1000; static unsigned long long base = 0; if(!base) base = time - 1000000; return time - base; #endif }
unsigned SystemCall::getCurrentSystemTime() { #ifndef TARGET_TOOL if(RoboCupCtrl::controller) return RoboCupCtrl::controller->getTime(); else #endif return getRealSystemTime(); }
unsigned long long SystemCall::getCurrentThreadTime() { #if defined(WIN32) || defined(MACOSX) // FIXME return (unsigned long long) getRealSystemTime() * 1000; #else clockid_t cid; struct timespec ts; VERIFY(pthread_getcpuclockid(pthread_self(), &cid) == 0); VERIFY(clock_gettime(cid, &ts) == 0); unsigned long long time = ts.tv_sec * 1000000ll + ts.tv_nsec / 1000; static unsigned long long base = 0; if(!base) base = time - 1000000; return time - base; #endif }
unsigned SystemCall::getSystemTimeBase() { if(!base) (void) getRealSystemTime(); return base; }
unsigned SystemCall::getCurrentSystemTime() { return getRealSystemTime(); }