PerfTimer.cpp 983 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // CPerfTimer - a simple Win32 performance counter wrapper
  2. // by Dean Wyant [email protected]
  3. #include "stdafx.h"
  4. #include "PerfTimer.h"
  5. // Declare and initialize static member vars that get set only once and never change
  6. __int64 CPerfTimer::m_Freq = 0;
  7. __int64 CPerfTimer::m_Adjust = 0;
  8. // All functions defined inline for speed. After all, the performance counter is
  9. // supposed to be able to time very short events fairly accurately.
  10. BOOL CPerfTimer::IsSupported()
  11. { // Returns FALSE if performance counter not supported.
  12. // Call after constructing at least one CPerfTimer
  13. return (m_Freq > 1);
  14. }
  15. const double CPerfTimer::Resolution()
  16. { // Returns timer resolution in seconds
  17. return 1.0/(double)m_Freq;
  18. }
  19. const double CPerfTimer::Resolutionms()
  20. { // Returns timer resolution in milliseconds
  21. return 1000.0/(double)m_Freq;
  22. }
  23. const double CPerfTimer::Resolutionus()
  24. { // Returns timer resolution in microseconds
  25. return 1000000.0/(double)m_Freq;
  26. }