diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-12-19 15:31:47 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-12-19 15:31:47 +0000 |
commit | 8679d895d332162694477f06d6f369ee5652e458 (patch) | |
tree | ab01c3f5c2e9b3f85e634076f0579605b41c2f6b /bench/btl/generic_bench | |
parent | 22875683b9c382a8f327630014ae33d22ca64588 (diff) |
various MSVC fixes in BTL
Diffstat (limited to 'bench/btl/generic_bench')
-rw-r--r-- | bench/btl/generic_bench/btl.hh | 8 | ||||
-rwxr-xr-x | bench/btl/generic_bench/timers/portable_timer.hh | 94 |
2 files changed, 66 insertions, 36 deletions
diff --git a/bench/btl/generic_bench/btl.hh b/bench/btl/generic_bench/btl.hh index 6d6e048b3..38e2c5f45 100644 --- a/bench/btl/generic_bench/btl.hh +++ b/bench/btl/generic_bench/btl.hh @@ -38,7 +38,13 @@ #define BTL_DONT_INLINE #endif -#ifndef __INTEL_COMPILER +#if (defined __GNUC__) +#define BTL_ASM_COMMENT(X) asm("#"X) +#else +#define BTL_ASM_COMMENT(X) +#endif + +#if (defined __GNUC__) && (!defined __INTEL_COMPILER) #define BTL_DISABLE_SSE_EXCEPTIONS() { \ int aux; \ asm( \ diff --git a/bench/btl/generic_bench/timers/portable_timer.hh b/bench/btl/generic_bench/timers/portable_timer.hh index de50394f9..30fc4e883 100755 --- a/bench/btl/generic_bench/timers/portable_timer.hh +++ b/bench/btl/generic_bench/timers/portable_timer.hh @@ -26,10 +26,6 @@ #include <cstdlib> #include <time.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <unistd.h> -#include <sys/times.h> #define USEC_IN_SEC 1000000 @@ -38,38 +34,65 @@ // timer -------------------------------------------------------------------// // A timer object measures CPU time. +#ifdef _MSC_VER -// class Portable_Timer -// { -// public: -// -// Portable_Timer( void ) -// { -// } -// -// -// void start() { m_val = getTime(); } -// -// void stop() { m_val = getTime() - m_val; } -// -// double elapsed() { return m_val; } -// -// double user_time() { return elapsed(); } -// -// -// private: -// -// static inline double getTime(void) -// { -// struct timeval tv; -// struct timezone tz; -// gettimeofday(&tv, &tz); -// return (double)tv.tv_sec + 1.e-6 * (double)tv.tv_usec; -// } -// -// double m_val; -// -// }; // Portable_Timer +#define NOMINMAX +#include <windows.h> + +/*#ifndef hr_timer +#include "hr_time.h" +#define hr_timer +#endif*/ + + class Portable_Timer + { + public: + + typedef struct { + LARGE_INTEGER start; + LARGE_INTEGER stop; + } stopWatch; + + + Portable_Timer() + { + startVal.QuadPart = 0; + stopVal.QuadPart = 0; + QueryPerformanceFrequency(&frequency); + } + + void start() { QueryPerformanceCounter(&startVal); } + + void stop() { QueryPerformanceCounter(&stopVal); } + + double elapsed() { + LARGE_INTEGER time; + time.QuadPart = stopVal.QuadPart - startVal.QuadPart; + return LIToSecs(time); + } + + double user_time() { return elapsed(); } + + + private: + + double LIToSecs(LARGE_INTEGER& L) { + return ((double)L.QuadPart /(double)frequency.QuadPart) ; + } + + LARGE_INTEGER startVal; + LARGE_INTEGER stopVal; + LARGE_INTEGER frequency; + + + }; // Portable_Timer + +#else + +#include <sys/time.h> +#include <sys/resource.h> +#include <unistd.h> +#include <sys/times.h> class Portable_Timer { @@ -137,5 +160,6 @@ private: }; // Portable_Timer +#endif #endif // PORTABLE_TIMER_HPP |