diff --git a/paddle/fluid/platform/timer.cc b/paddle/fluid/platform/timer.cc index 75d4e5cbf90bd81c73756605eacc6b0c15a63e9d..0c1dd53037c4044627849df2ee4e15e8ec830448 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 7951d97044f62943f749542fdabc489c7e9d973d..1cd5d9936d38d7e80d2a685604f467e055fd9c0b 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 {