rlm@1: // CPerfTimer - a simple Win32 performance counter wrapper rlm@1: // by Dean Wyant dwyant@mindspring.com rlm@1: rlm@1: #include "stdafx.h" rlm@1: #include "PerfTimer.h" rlm@1: rlm@1: // Declare and initialize static member vars that get set only once and never change rlm@1: __int64 CPerfTimer::m_Freq = 0; rlm@1: __int64 CPerfTimer::m_Adjust = 0; rlm@1: rlm@1: // All functions defined inline for speed. After all, the performance counter is rlm@1: // supposed to be able to time very short events fairly accurately. rlm@1: rlm@1: rlm@1: rlm@1: BOOL CPerfTimer::IsSupported() rlm@1: { // Returns FALSE if performance counter not supported. rlm@1: // Call after constructing at least one CPerfTimer rlm@1: return (m_Freq > 1); rlm@1: } rlm@1: rlm@1: const double CPerfTimer::Resolution() rlm@1: { // Returns timer resolution in seconds rlm@1: return 1.0/(double)m_Freq; rlm@1: } rlm@1: rlm@1: const double CPerfTimer::Resolutionms() rlm@1: { // Returns timer resolution in milliseconds rlm@1: return 1000.0/(double)m_Freq; rlm@1: } rlm@1: rlm@1: const double CPerfTimer::Resolutionus() rlm@1: { // Returns timer resolution in microseconds rlm@1: return 1000000.0/(double)m_Freq; rlm@1: }