From f84de4ac212d3f6beee266236da70c467a7a1d86 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Mon, 9 Sep 2013 16:26:44 +0200 Subject: [PATCH] Moving timing back to reliable but uugly code --- Util/TimingUtil.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) 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_ */