| 31 | * windows and linux. */ |
| 32 | |
| 33 | int64 GetTimeMs64() |
| 34 | { |
| 35 | #ifdef WIN32 |
| 36 | /* Windows */ |
| 37 | FILETIME ft; |
| 38 | LARGE_INTEGER li; |
| 39 | |
| 40 | /* Get the amount of 100 nano seconds intervals elapsed since January 1, 1601 (UTC) and copy it |
| 41 | * to a LARGE_INTEGER structure. */ |
| 42 | GetSystemTimeAsFileTime(&ft); |
| 43 | li.LowPart = ft.dwLowDateTime; |
| 44 | li.HighPart = ft.dwHighDateTime; |
| 45 | |
| 46 | uint64 ret = li.QuadPart; |
| 47 | ret -= 116444736000000000LL; /* Convert from file time to UNIX epoch time. */ |
| 48 | // ret /= 10000; /* From 100 nano seconds (10^-7) to 1 millisecond (10^-3) intervals */ |
| 49 | ret /= 10; /* 1 microsecond (10^-6) */ |
| 50 | |
| 51 | return ret; |
| 52 | #else |
| 53 | /* Linux */ |
| 54 | struct timeval tv; |
| 55 | |
| 56 | gettimeofday(&tv, nullptr); |
| 57 | |
| 58 | uint64 ret = tv.tv_usec; |
| 59 | /* Convert from micro seconds (10^-6) to milliseconds (10^-3) */ |
| 60 | ret /= 1000; |
| 61 | |
| 62 | /* Adds the seconds (10^0) after converting them to milliseconds (10^-3) */ |
| 63 | ret += (tv.tv_sec * 1000); |
| 64 | |
| 65 | return ret; |
| 66 | #endif |
| 67 | } |
| 68 | |
| 69 | #define ClockVariables \ |
| 70 | int64 startJob, stopJob; \ |