diff --git a/Util/TimingUtil.h b/Util/TimingUtil.h index 66f8c22bd..2762a3491 100644 --- a/Util/TimingUtil.h +++ b/Util/TimingUtil.h @@ -36,11 +36,29 @@ or see http://www.gnu.org/licenses/agpl.txt. // return duration.count(); // } +#include +#include + + +#ifdef _WIN32 +#include +#include +#include +void gettimeofday(struct timeval* t,void* timezone) { + struct _timeb timebuffer; + _ftime( &timebuffer ); + t->tv_sec=timebuffer.time; + t->tv_usec=1000*timebuffer.millitm; +} +#else #include -inline double get_timestamp() { - timeval local_time; - gettimeofday(&local_time, NULL); - return local_time.tv_sec+(local_time.tv_usec/1000000.0); +#endif + +/** Returns a timestamp (now) in seconds (incl. a fractional part). */ +static inline double get_timestamp() { + struct timeval tp; + gettimeofday(&tp, NULL); + return double(tp.tv_sec) + tp.tv_usec / 1000000.; } #endif /* TIMINGUTIL_H_ */