diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/PerfTimer.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,35 @@
     1.4 +// CPerfTimer - a simple Win32 performance counter wrapper
     1.5 +// by Dean Wyant dwyant@mindspring.com
     1.6 +
     1.7 +#include "stdafx.h"
     1.8 +#include "PerfTimer.h"
     1.9 +
    1.10 +// Declare and initialize static member vars that get set only once and never change
    1.11 +__int64 CPerfTimer::m_Freq = 0; 
    1.12 +__int64 CPerfTimer::m_Adjust = 0; 
    1.13 +
    1.14 +// All functions defined inline for speed. After all, the performance counter is 
    1.15 +// supposed to be able to time very short events fairly accurately.
    1.16 +
    1.17 +
    1.18 +
    1.19 +BOOL CPerfTimer::IsSupported()
    1.20 +{ // Returns FALSE if performance counter not supported.
    1.21 +	// Call after constructing at least one CPerfTimer
    1.22 +	return (m_Freq > 1);
    1.23 +}
    1.24 +
    1.25 +const double CPerfTimer::Resolution()   
    1.26 +{ // Returns timer resolution in seconds
    1.27 +	return 1.0/(double)m_Freq; 
    1.28 +}
    1.29 +
    1.30 +const double CPerfTimer::Resolutionms() 
    1.31 +{ // Returns timer resolution in milliseconds
    1.32 +	return 1000.0/(double)m_Freq; 
    1.33 +}
    1.34 +
    1.35 +const double CPerfTimer::Resolutionus() 
    1.36 +{ // Returns timer resolution in microseconds
    1.37 +	return 1000000.0/(double)m_Freq; 
    1.38 +}