_clock_win32hpcount.h

Go to the documentation of this file.
00001 
00025 /* === S T A R T =========================================================== */
00026 
00027 #ifndef __ETL__CLOCK_WIN32HPCOUNT_H
00028 #define __ETL__CLOCK_WIN32HPCOUNT_H
00029 
00030 /* === H E A D E R S ======================================================= */
00031 
00032 #define WIN32_LEAN_AND_MEAN
00033 #include <windows.h>
00034 
00035 /* === M A C R O S ========================================================= */
00036 
00037 #if defined(__GNUG__) && defined(__int64)
00038 #undef __int64
00039 #define __int64 long long int
00040 #endif
00041 
00042 /* === T Y P E D E F S ===================================================== */
00043 
00044 /* === C L A S S E S & S T R U C T S ======================================= */
00045 
00046 _ETL_BEGIN_NAMESPACE
00047 
00048 class clock_desc_win32hpcount
00049 {
00050 public:
00051     typedef double value_type;
00052 
00053     static bool realtime()
00054     { return true; }
00055 
00056     static bool proctime()
00057     { return false; }
00058 
00059     static value_type
00060     one_second()
00061     { return 1.0f; }
00062 
00063     static value_type precision()
00064     {
00065         __int64 freq;
00066         QueryPerformanceFrequency((LARGE_INTEGER*)&freq);
00067         return one_second()/(value_type)freq;
00068     }
00069 
00070     static const char *description()
00071     { return "Win32 QueryPerformanceCounter()"; };
00072 
00073 protected:
00074     typedef __int64 timestamp;
00075 
00076     static void
00077     get_current_time(timestamp &x)
00078     { QueryPerformanceCounter((LARGE_INTEGER*)&x);}
00079 
00080     static timestamp
00081     get_current_time()
00082     { timestamp ret; QueryPerformanceCounter((LARGE_INTEGER*)&ret); return ret; }
00083 
00084     static value_type
00085     timestamp_to_seconds(const timestamp &x)
00086     { return precision()*x; }
00087 
00088     static timestamp
00089     seconds_to_timestamp(const value_type &x)
00090     { return (timestamp)(x/precision()); }
00091 };
00092 
00093 _ETL_END_NAMESPACE
00094 
00095 /* === E N D =============================================================== */
00096 
00097 #endif
00098 

Generated on Fri Jun 22 14:33:39 2007 for ETL by  doxygen 1.5.2