Filter Library | Camera | Interface Physics |
00001 // CPerfTimer - a simple Win32 performance counter wrapper 00002 // by Dean Wyant dwyant@mindspring.com 00003 00004 #include "stdafx.h" 00005 #include "PerfTimer.h" 00006 00007 // Declare and initialize static member vars that get set only once and never change 00008 __int64 CPerfTimer::m_Freq = 0; 00009 __int64 CPerfTimer::m_Adjust = 0; 00010 00011 // All functions defined inline for speed. After all, the performance counter is 00012 // supposed to be able to time very short events fairly accurately. 00013 00014 00015 00016 BOOL CPerfTimer::IsSupported() 00017 { // Returns FALSE if performance counter not supported. 00018 // Call after constructing at least one CPerfTimer 00019 return (m_Freq > 1); 00020 } 00021 00022 const double CPerfTimer::Resolution() 00023 { // Returns timer resolution in seconds 00024 return 1.0/(double)m_Freq; 00025 } 00026 00027 const double CPerfTimer::Resolutionms() 00028 { // Returns timer resolution in milliseconds 00029 return 1000.0/(double)m_Freq; 00030 } 00031 00032 const double CPerfTimer::Resolutionus() 00033 { // Returns timer resolution in microseconds 00034 return 1000000.0/(double)m_Freq; 00035 } 00036 00037 00038