MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / GetTimeInMillis

Function GetTimeInMillis

rtpose_wrapper/src/gtest/gtest-all.cpp:2068–2117  ·  view source on GitHub ↗

Returns the current time in milliseconds.

Source from the content-addressed store, hash-verified

2066
2067// Returns the current time in milliseconds.
2068TimeInMillis GetTimeInMillis() {
2069#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
2070 // Difference between 1970-01-01 and 1601-01-01 in milliseconds.
2071 // http://analogous.blogspot.com/2005/04/epoch.html
2072 const TimeInMillis kJavaEpochToWinFileTimeDelta =
2073 static_cast<TimeInMillis>(116444736UL) * 100000UL;
2074 const DWORD kTenthMicrosInMilliSecond = 10000;
2075
2076 SYSTEMTIME now_systime;
2077 FILETIME now_filetime;
2078 ULARGE_INTEGER now_int64;
2079 // TODO(kenton@google.com): Shouldn't this just use
2080 // GetSystemTimeAsFileTime()?
2081 GetSystemTime(&now_systime);
2082 if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
2083 now_int64.LowPart = now_filetime.dwLowDateTime;
2084 now_int64.HighPart = now_filetime.dwHighDateTime;
2085 now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
2086 kJavaEpochToWinFileTimeDelta;
2087 return now_int64.QuadPart;
2088 }
2089 return 0;
2090#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
2091 __timeb64 now;
2092
2093# ifdef _MSC_VER
2094
2095 // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
2096 // (deprecated function) there.
2097 // TODO(kenton@google.com): Use GetTickCount()? Or use
2098 // SystemTimeToFileTime()
2099# pragma warning(push) // Saves the current warning state.
2100# pragma warning(disable:4996) // Temporarily disables warning 4996.
2101 _ftime64(&now);
2102# pragma warning(pop) // Restores the warning state.
2103# else
2104
2105 _ftime64(&now);
2106
2107# endif // _MSC_VER
2108
2109 return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
2110#elif GTEST_HAS_GETTIMEOFDAY_
2111 struct timeval now;
2112 gettimeofday(&now, NULL);
2113 return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
2114#else
2115# error "Don't know how to get the current time on your system."
2116#endif
2117}
2118
2119// Utilities
2120

Callers 3

GetRandomSeedFromFlagFunction · 0.85
RunMethod · 0.85
RunAllTestsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected