Click here to Skip to main content
15,909,325 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: File size limit Pin
Andrew Admire23-May-05 10:16
Andrew Admire23-May-05 10:16 
GeneralRe: File size limit Pin
David Crow23-May-05 10:37
David Crow23-May-05 10:37 
GeneralRe: File size limit Pin
Rick York23-May-05 10:28
mveRick York23-May-05 10:28 
GeneralRe: File size limit Pin
David Crow23-May-05 10:41
David Crow23-May-05 10:41 
GeneralRe: File size limit Pin
Andrew Admire23-May-05 10:46
Andrew Admire23-May-05 10:46 
GeneralRe: File size limit Pin
Rick York23-May-05 12:22
mveRick York23-May-05 12:22 
GeneralRe: File size limit Pin
24-May-05 3:54
suss24-May-05 3:54 
GeneralRe: File size limit Pin
Rick York23-May-05 12:29
mveRick York23-May-05 12:29 
In case you want it - here's the CElapsed timer. I use it for high-resolution timing. It typically has a an overhead of around 2uS, depending on CPU, so it can usually time to within 10uS.


//
// CElapsed.h - header for the CElapsed class
//
//	Copyright 1998-2005 by Rick York
//	This class is free for use in any and all applications for any purpose.
//
//	To use this class include this header and do the following :
//
//	CElapsed timer;	// instantiate a timer object.
//	double start = timer.Elapsed();		// start timing
//	...				// your code here
//	double TimeInSeconds = timer.Elapsed( start);	// obtain elapsed time
//

#ifndef _CELAPSED_H
#define _CELAPSED_H
#else
#error repeated include of this file
#endif

/***
#ifndef _CELAPSED_H
#include "CElapsed.h"
#endif
 ***/


class CElapsed
{
private :
	double	m_Period;
	int		m_Initialized;
	__int64 m_Frequency;

public :
	CElapsed()		// constructor
		{
		// get the frequency of the counter
		m_Initialized = QueryPerformanceFrequency( (LARGE_INTEGER *)&m_Frequency );
		if( ! m_Initialized )
			m_Period = 0.0;
		else
			m_Period = 1.0 / (double)m_Frequency;	// save period of clock
		}

	double Elapsed( double begin=0.0 )	// stop timing and get elapsed time in seconds
		{
		// get the ending counter value
		__int64 endtime;
		QueryPerformanceCounter( (LARGE_INTEGER *)&endtime );

		// convert counts to time in seconds and return it
		double endsecs = endtime * m_Period;
		return endsecs - begin;
		}

	BOOL	Initialized()	// returns true if the perf counter is available
		{ return m_Initialized; }

	__int64	GetFreq()	// return perf counter frequency as large int
		{ return m_Frequency; }

	double	FromMilliSecs( UINT millisecs )
		{ return 0.001 * millisecs; }

	//IMPORTANT!  This is a 'spin loop" delay.  The calling thread hogs the
	// CPU while the delay is in progress and there is less than 1 mS to go.
	// For longer delays than about 3 mS or so use Sleep() which gives up
	// the processor while it waits.

	void Delay( double amount )
		{
			double delta;
			double delaytime;
			double start = Elapsed( 0.0 );
			while( true )
			{
				delaytime = Elapsed( start );
				delta = amount - delaytime;
				if( delta <= 0.0 )
					break;
				if( delta > 0.0012 )	// more than 1mS left
					Sleep( 1 );			// give the CPU a break
			}
		}
};

QuestionHow to display a tooltip for ComboboxEx Pin
qin138823-May-05 7:26
qin138823-May-05 7:26 
AnswerRe: How to display a tooltip for ComboboxEx Pin
David Crow23-May-05 7:34
David Crow23-May-05 7:34 
GeneralRe: How to display a tooltip for ComboboxEx Pin
qin138823-May-05 9:32
qin138823-May-05 9:32 
GeneralRe: How to display a tooltip for ComboboxEx Pin
David Crow23-May-05 9:59
David Crow23-May-05 9:59 
GeneralReading CArchive in Serialize Pin
vasanth100423-May-05 7:14
vasanth100423-May-05 7:14 
GeneralRe: Reading CArchive in Serialize Pin
David Crow23-May-05 7:31
David Crow23-May-05 7:31 
GeneralRe: Reading CArchive in Serialize Pin
vasanth100423-May-05 7:36
vasanth100423-May-05 7:36 
GeneralRe: Reading CArchive in Serialize Pin
David Crow23-May-05 7:45
David Crow23-May-05 7:45 
GeneralRe: Reading CArchive in Serialize Pin
vasanth100423-May-05 7:48
vasanth100423-May-05 7:48 
GeneralRe: Reading CArchive in Serialize Pin
David Crow23-May-05 7:50
David Crow23-May-05 7:50 
GeneralRe: Reading CArchive in Serialize Pin
vasanth100423-May-05 8:02
vasanth100423-May-05 8:02 
GeneralRe: Reading CArchive in Serialize Pin
David Crow23-May-05 8:56
David Crow23-May-05 8:56 
GeneralOpenGL flickers despite double buffering Pin
User 58261923-May-05 6:58
User 58261923-May-05 6:58 
GeneralRe: OpenGL flickers despite double buffering Pin
LunaticFringe23-May-05 7:35
LunaticFringe23-May-05 7:35 
GeneralRe: OpenGL flickers despite double buffering Pin
cmk24-May-05 5:05
cmk24-May-05 5:05 
GeneralDrawing lines Pin
merkit23-May-05 6:18
merkit23-May-05 6:18 
GeneralOnSizing not firing in dialog Pin
vineas23-May-05 5:19
vineas23-May-05 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.