| 1858 | } |
| 1859 | |
| 1860 | double 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 | |
| 1882 | uint64_t timer_int() { |
| 1883 | #ifdef _WIN32 |
no outgoing calls
no test coverage detected