MCPcopy Create free account
hub / github.com/apple/foundationdb / timer

Function timer

flow/Platform.actor.cpp:1860–1880  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1858}
1859
1860double timer() {
1861#ifdef _WIN32
1862 static const int64_t FILETIME_C_EPOCH =
1863 11644473600LL *
1864 10000000LL; // Difference between FILETIME epoch (1601) and Unix epoch (1970) in 100ns FILETIME ticks
1865 FILETIME fileTime;
1866 GetSystemTimeAsFileTime(&fileTime);
1867 static_assert(sizeof(fileTime) == sizeof(uint64_t), "FILETIME size wrong");
1868 return (*(uint64_t*)&fileTime - FILETIME_C_EPOCH) * 100e-9;
1869#elif defined(__linux__) || defined(__FreeBSD__)
1870 struct timespec ts;
1871 clock_gettime(CLOCK_REALTIME, &ts);
1872 return double(ts.tv_sec) + (ts.tv_nsec * 1e-9);
1873#elif defined(__APPLE__)
1874 struct timeval tv;
1875 gettimeofday(&tv, nullptr);
1876 return double(tv.tv_sec) + (tv.tv_usec * 1e-6);
1877#else
1878#error Port me!
1879#endif
1880};
1881
1882uint64_t timer_int() {
1883#ifdef _WIN32

Callers 10

getCurrentTimeMethod · 0.70
getSystemStatisticsFunction · 0.70
checkThreadFunction · 0.70
IndexedSet.cppFile · 0.70
timerMethod · 0.70
logTimeOffsetMethod · 0.70
signal_handlerMethod · 0.70
opTimerClass · 0.50
~opTimerMethod · 0.50
bench_timerFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected