Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

hrtimer.h

00001 #ifndef CRYPTOPP_HRTIMER_H
00002 #define CRYPTOPP_HRTIMER_H
00003 
00004 #include "cryptopp_config.h"
00005 
00006 NAMESPACE_BEGIN(CryptoPP)
00007 
00008 #ifdef HIGHRES_TIMER_AVAILABLE
00009 
00010 //! high resolution timer
00011 class Timer
00012 {
00013 public:
00014         enum Unit {SECONDS, MILLISECONDS, MICROSECONDS};
00015         Timer(Unit unit, bool stuckAtZero = false)      : m_timerUnit(unit), m_stuckAtZero(stuckAtZero), m_started(false) {}
00016 
00017         static word64 GetCurrentTimerValue();   // GetCurrentTime is a macro in MSVC 6.0
00018         static unsigned long ConvertTo(word64 t, Unit unit);
00019 
00020         // this is not the resolution, just a conversion factor into milliseconds
00021         static inline unsigned int TicksPerMillisecond()
00022         {
00023 #if defined(CRYPTOPP_WIN32_AVAILABLE)
00024                 return 10000;
00025 #elif defined(CRYPTOPP_UNIX_AVAILABLE) || defined(macintosh)
00026                 return 1000;
00027 #endif
00028         }
00029 
00030         void StartTimer();
00031         unsigned long ElapsedTime();
00032 
00033 private:
00034         Unit m_timerUnit;       // HPUX workaround: m_unit is a system macro on HPUX
00035         bool m_stuckAtZero, m_started;
00036         word64 m_start;
00037 };
00038 
00039 #endif
00040 
00041 NAMESPACE_END
00042 
00043 #endif

Generated on Sun Mar 14 20:44:26 2004 for Crypto++ by doxygen 1.3.6-20040222