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
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();
00018 static unsigned long ConvertTo(word64 t, Unit unit);
00019
00020
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;
00035 bool m_stuckAtZero, m_started;
00036 word64 m_start;
00037 };
00038
00039 #endif
00040
00041 NAMESPACE_END
00042
00043 #endif