我想实现一个函数跟踪器,它将跟踪一个函数执行的时间.我有以下课程: -
class FuncTracer
{
public:
FuncTracer(LPCTSTR strFuncName_in)
{
m_strFuncName[0] = _T('\0');
if( strFuncName_in ||
_T('\0') != strFuncName_in[0])
{
_tcscpy(m_strFuncName,strFuncName_in);
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Entering Func:- <%s>"),m_strFuncName);
LOG(strLog)
m_dwEnterTime = GetTickCount();
}
}
~FuncTracer()
{
TCHAR strLog[MAX_PATH];
_stprintf(strLog,_T("Leaving Func:- <%s>, Time inside the func <%d> ms"),m_strFuncName, GetTickCount()-m_dwEnterTime);
LOG(strLog)
}
private:
TCHAR m_strFuncName[MAX_PATH];
DWORD m_dwEnterTime;
};
void TestClass::TestFunction()
{
// I want to avoid writing the function name maually..
// Is there any macro (__LINE__)or some other way to
// get the function …Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio 2005中的DLL和EXE项目.在DLL的代码中,有一个可扩展数组类的模板:
template <class Type>
class GArray
{
Type *p;
uint32 len;
uint32 alloc;
protected:
bool fixed;
public:
/// Constructor
GArray(int PreAlloc = 0)
{
p = 0;
len = 0;
fixed = false;
alloc = PreAlloc;
if (alloc)
{
int Bytes = sizeof(Type) * alloc;
p = (Type*) malloc(Bytes);
if (p)
{
memset(p, 0, Bytes);
}
else
{
alloc = 0;
}
}
}
/// Destructor
~GArray()
{
Length(0);
}
/// Returns the number of used entries
uint32 …Run Code Online (Sandbox Code Playgroud)