#ifndef _PerfChecker_h__
#define _PerfChecker_h__
#include <string>
using namespace std;

enum PERF_CHECK_LEVEL
{
	DEBUG_CHECK_LEVEL = 1,
	DETAIL_CHECK_LEVEL = 2,
	INFO_CHECK_LEVEL = 3,
	WARNING_CHECK_LEVEL = 4
};

#ifdef WIN32
#define DEBUG_PERF_CHECK()     PerfChecker __local_function_checker__(__FUNCSIG__,__FILE__,__LINE__,DEBUG_CHECK_LEVEL)

#define DETAIL_PERF_CHECK() 	    PerfChecker __local_function_checker__(__FUNCSIG__,__FILE__,__LINE__,DETAIL_CHECK_LEVEL)

#define INFO_PERF_CHECK() 	//PerfChecker __local_function_checker__(__FUNCSIG__,__FILE__,__LINE__,INFO_CHECK_LEVEL)


#define WARNING_PERF_CHECK() 	PerfChecker __local_function_checker__(__FUNCSIG__,__FILE__,__LINE__,WARNING_CHECK_LEVEL)

#define INFO_PERF_CHECK_EX(X) 	//PerfChecker __local_function_checker__(X,__FILE__,__LINE__,INFO_CHECK_LEVEL)

#else

#define DEBUG_PERF_CHECK()     PerfChecker __local_function_checker__(__FUNCTION__,__FILE__,__LINE__,DEBUG_CHECK_LEVEL)

#define DETAIL_PERF_CHECK() 	    PerfChecker __local_function_checker__(__FUNCTION__,__FILE__,__LINE__,DETAIL_CHECK_LEVEL)

#define INFO_PERF_CHECK() 	PerfChecker __local_function_checker__(__FUNCTION__,__FILE__,__LINE__,INFO_CHECK_LEVEL)


#define WARNING_PERF_CHECK() 	PerfChecker __local_function_checker__(__FUNCTION__,__FILE__,__LINE__,WARNING_CHECK_LEVEL)

#define INFO_PERF_CHECK_EX(X) 	PerfChecker __local_function_checker__(X,__FILE__,__LINE__,INFO_CHECK_LEVEL)

#endif

#define PERF_CHECKER(_checker)	PerfChecker _checker(__FUNCTION__, __FILE__,__LINE__,INFO_CHECK_LEVEL)

class PerfChecker
{
	long long m_nStartTime;
	long long m_nCheckPointTime;
	string m_strFunctionName;
	string m_strSourceFile;
	int m_nLineNum;
	PERF_CHECK_LEVEL m_eCheckLevel;

public:
	PerfChecker(const char * pszFunctionName,const char * pszSourceFile,int nLineNum,PERF_CHECK_LEVEL checkLevel);
	~PerfChecker(void);

	void CheckPoint(const char * pszCheckPointName);

private:
	void Output(const char * pszCheckPointerName, long long nStartTime, long long nCurTime);
};

long long Perf_GetTime();
double Perf_ConvertTime(long long use_time);

#endif
