### c++
#ifdef _WIN32
#define ENTER { \
LARGE_INTEGER begin, end, freq; \
QueryPerformanceFrequency(&freq); \
QueryPerformanceCounter(&begin);
#define LEAVE \
QueryPerformanceCounter(&end); \
double elapsed_time = (double)(end.QuadPart - begin.QuadPart) / freq.QuadPart; \
printf("%s:%d] %3.2f elapsed\n", __FUNCTION__, __LINE__, elapsed_time); \
#else
#include <sys/time.h>
#define ENTER { \
struct timeval stime, etime; \
unsigned int performed_time; \
gettimeofday(&stime, NULL);
#define LEAVE \
gettimeofday(&etime, NULL); \
performed_time = etime.tv_sec - stime.tv_sec; \
performed_time = performed_time * 1000000 + etime.tv_usec - stime.tv_usec; \
printf("%s:%d] %d elapsed\n", __func__, __LINE__, performed_time); \
}
#endif
'프로그래밍 언어 > C/C++' 카테고리의 다른 글
calloc vs malloc (7) | 2011.04.06 |
---|---|
[C언어] a - b < 0 vs. a < b (0) | 2010.10.25 |
__builtin_expect 키워드 (0) | 2010.09.10 |
gcc 업그레이드 (4.5.0) (0) | 2010.07.21 |
Header안에 static 변수 (0) | 2010.02.21 |