카테고리 없음

MFC - 함수 실행시간 측정(디버그 모드)

안녕1999 2017. 11. 6. 23:30

debug_print_run_time.h


msec단위로 간단히 측정가능. TRACE를 printf등으로 바꾸면, 파일에 기록가능

#ifndef DEBUG_print_run_time_H

#define DEBUG_print_run_time_H


//함수 실행시간 측정. //ex) //void func1() 

//{ 

// DEBUG_print_run_time("func1"); 

// ... 

//}

class class_DEBUG_print_run_time 

{

public:

DWORD t;TCHAR *m_log;

class_DEBUG_print_run_time(TCHAR *log) 

{

t=GetTickCount();

m_log=log;

//TRACE(_T("\r\n#START:%s\r\n"),m_log);

}

~class_DEBUG_print_run_time() 

{

t=GetTickCount()-t; if(t>5)

{

TRACE(_T("%s,%d msec\r\n"),m_log,t);

}

}

};

#ifdef _DEBUG

#define DEBUG_print_run_time(log) class_DEBUG_print_run_time _a(log)

#else

#define DEBUG_print_run_time(log)

#endif

#endif