⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugutils.cpp

📁 A Model-View-Controller Framework that integrates with the MFC Doc/View architecture.
💻 CPP
字号:
#include "StdAfx.h"
#include "DebugUtils.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

namespace SbjCore
{
	namespace Utils
	{
		namespace Debug
		{
			//	Found on CodeProject, no copyright or license attached
			//	Author:		Chen Venkataraman (venkatar@sig.com)
			//	Date:		Wed Dec 6, 2001
			HighResElapsedTimer::HighResElapsedTimer(LPCTSTR strName, bool bTimeRelease /*= false*/) : 
				m_strName(strName),
				m_bTimeRelease(bTimeRelease)
			{
#ifdef _DEBUG
				if (m_llFrequency == 0)			// frequency value not yet set
				{
					LARGE_INTEGER	liFrequency;

					QueryPerformanceFrequency(&liFrequency);
					m_llFrequency = liFrequency.QuadPart;
				}

				QueryPerformanceCounter(&m_llCounter);
#else
				if (m_bTimeRelease)
				{
					if (m_llFrequency == 0)			// frequency value not yet set
					{
						LARGE_INTEGER	liFrequency;

						QueryPerformanceFrequency(&liFrequency);
						m_llFrequency = liFrequency.QuadPart;
					}

					QueryPerformanceCounter(&m_llCounter);
				}
#endif
			}

			HighResElapsedTimer::~HighResElapsedTimer()
			{
				GetTime();
			}

			CString HighResElapsedTimer::GetTime()
			{
				CString s;
#ifdef _DEBUG
				LARGE_INTEGER		liNow;
				QueryPerformanceCounter(&liNow);
				double				duration = (double)(liNow.QuadPart - m_llCounter.QuadPart)/m_llFrequency;
				s.Format(_T("%s : Elapsed time = %.5lf seconds\n"), m_strName, duration);
				TRACE(s);
#else
				if (m_bTimeRelease)
				{
					LARGE_INTEGER		liNow;
					QueryPerformanceCounter(&liNow);
					double				duration = (double)(liNow.QuadPart - m_llCounter.QuadPart)/m_llFrequency;
					s.Format(_T("%s : Elapsed time = %.5lf seconds\n"), m_strName, duration);
					TRACE(s);
				}
#endif
				return s;
			}
			
			/* static */
			LONGLONG HighResElapsedTimer::m_llFrequency = 0;


		}
	}
}


//*** Modification History ***
// $Log:  $

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -