diff --git a/paddle/fluid/platform/timer.cc b/paddle/fluid/platform/timer.cc index 75d4e5cbf9..0c1dd53037 100644 --- a/paddle/fluid/platform/timer.cc +++ b/paddle/fluid/platform/timer.cc @@ -17,6 +17,27 @@ limitations under the License. */ namespace paddle { namespace platform { +#if defined _WIN32 +static int gettimeofday(struct timeval *tp, void *tzp) { + time_t clock; + struct tm tm; + SYSTEMTIME wtm; + + GetLocalTime(&wtm); + tm.tm_year = wtm.wYear - 1900; + tm.tm_mon = wtm.wMonth - 1; + tm.tm_mday = wtm.wDay; + tm.tm_hour = wtm.wHour; + tm.tm_min = wtm.wMinute; + tm.tm_sec = wtm.wSecond; + tm.tm_isdst = -1; + clock = mktime(&tm); + tp->tv_sec = clock; + tp->tv_usec = wtm.wMilliseconds * 1000; + return (0); +} +#endif + void Timer::Reset() { _start.tv_sec = 0; _start.tv_usec = 0; diff --git a/paddle/fluid/platform/timer.h b/paddle/fluid/platform/timer.h index 7951d97044..1cd5d9936d 100644 --- a/paddle/fluid/platform/timer.h +++ b/paddle/fluid/platform/timer.h @@ -14,7 +14,16 @@ limitations under the License. */ #pragma once #include +#if defined __APPLE__ +#include +#else +#include +#if defined _WIN32 +#include +#else #include +#endif +#endif namespace paddle { namespace platform {