comparison src/win32/PerfTimer.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
comparison
equal deleted inserted replaced
0:8ced16adf2e1 1:f9f4f1b99eed
1 // CPerfTimer - a simple Win32 performance counter wrapper
2 // by Dean Wyant dwyant@mindspring.com
3
4 #include "stdafx.h"
5 #include "PerfTimer.h"
6
7 // Declare and initialize static member vars that get set only once and never change
8 __int64 CPerfTimer::m_Freq = 0;
9 __int64 CPerfTimer::m_Adjust = 0;
10
11 // All functions defined inline for speed. After all, the performance counter is
12 // supposed to be able to time very short events fairly accurately.
13
14
15
16 BOOL CPerfTimer::IsSupported()
17 { // Returns FALSE if performance counter not supported.
18 // Call after constructing at least one CPerfTimer
19 return (m_Freq > 1);
20 }
21
22 const double CPerfTimer::Resolution()
23 { // Returns timer resolution in seconds
24 return 1.0/(double)m_Freq;
25 }
26
27 const double CPerfTimer::Resolutionms()
28 { // Returns timer resolution in milliseconds
29 return 1000.0/(double)m_Freq;
30 }
31
32 const double CPerfTimer::Resolutionus()
33 { // Returns timer resolution in microseconds
34 return 1000000.0/(double)m_Freq;
35 }