00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef MEASURE_HPP
00024
#define MEASURE_HPP
00025
00026
#include <sys/time.h>
00027
00028 #define DBG_START_TIMER \
00029
{ \
00030
struct timeval timeStart; \
00031
struct timeval timeEnd; \
00032
struct timeval timeDiff; \
00033
if(gettimeofday(&timeStart, 0) == -1) \
00034
{ \
00035
std::cout << "[DBG-ERR] Failed to get start time." \
00036
<< std::endl; \
00037
}
00038
00039 #define DBG_STOP_TIMER(__label__) \
00040
if(gettimeofday(&timeEnd, 0) == -1) \
00041
{ \
00042
std::cout << "[DBG-ERR] Failed to get end time." \
00043
<< std::endl; \
00044
} \
00045
timeDiff.tv_sec = timeEnd.tv_sec - timeStart.tv_sec; \
00046
timeDiff.tv_usec = timeEnd.tv_usec - timeStart.tv_usec; \
00047
if (timeDiff.tv_usec < 0) \
00048
{ \
00049
--timeDiff.tv_sec; \
00050
timeDiff.tv_usec += 1000000; \
00051
} \
00052
std::cout << "[DBG] Time measurement '" << (__label__) << "':\t" \
00053
<< timeDiff.tv_sec << " secs, " \
00054
<< timeDiff.tv_usec << " usecs." << std::endl; \
00055
}
00056
00057
#endif // MEASURE_HPP