Click here to Skip to main content
15,895,815 members
Articles / Desktop Programming / MFC

Circular Buffer

Rate me:
Please Sign up or sign in to vote.
3.25/5 (3 votes)
15 Jun 2001 66.9K   1.6K   32  
A multi-threaded circular buffer program
// CPerfTimer - a simple Win32 performance counter wrapper
// by Dean Wyant dwyant@mindspring.com

#include "stdafx.h"
#include "PerfTimer.h"

// Declare and initialize static member vars that get set only once and never change
__int64 CPerfTimer::m_Freq = 0; 
__int64 CPerfTimer::m_Adjust = 0; 

// All functions defined inline for speed. After all, the performance counter is 
// supposed to be able to time very short events fairly accurately.



BOOL CPerfTimer::IsSupported()
{ // Returns FALSE if performance counter not supported.
  // Call after constructing at least one CPerfTimer
  return (m_Freq > 1);
}

const double CPerfTimer::Resolution()   
{ // Returns timer resolution in seconds
  return 1.0/(double)m_Freq; 
}

const double CPerfTimer::Resolutionms() 
{ // Returns timer resolution in milliseconds
  return 1000.0/(double)m_Freq; 
}

const double CPerfTimer::Resolutionus() 
{ // Returns timer resolution in microseconds
  return 1000000.0/(double)m_Freq; 
}



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions