2010-11-11 21:01:07 +01:00
|
|
|
#ifdef ELAPSED_TIME_IN_SECONDS
|
|
|
|
#undef ELAPSED_TIME_IN_SECONDS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ELAPSED_TIME_IN_uSECONDS
|
|
|
|
#undef ELAPSED_TIME_IN_uSECONDS
|
|
|
|
#endif
|
|
|
|
|
2011-09-05 17:00:37 +02:00
|
|
|
#ifdef __GNUC__
|
2010-11-11 21:01:07 +01:00
|
|
|
#include <sys/time.h>
|
2011-09-05 17:00:37 +02:00
|
|
|
#ifndef WIN32
|
|
|
|
#include <sys/resource.h>
|
2010-11-11 21:01:07 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#ifndef __CMPH_TIME_H__
|
|
|
|
#define __CMPH_TIME_H__
|
|
|
|
static inline void elapsed_time_in_seconds(double * elapsed_time)
|
|
|
|
{
|
|
|
|
struct timeval e_time;
|
|
|
|
if (gettimeofday(&e_time, NULL) < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*elapsed_time = (double)e_time.tv_sec + ((double)e_time.tv_usec/1000000.0);
|
|
|
|
}
|
2018-12-20 01:00:00 +01:00
|
|
|
static inline void dummy_elapsed_time_in_seconds(double * elapsed_time)
|
2010-11-11 21:01:07 +01:00
|
|
|
{
|
2018-12-20 01:00:00 +01:00
|
|
|
(void) elapsed_time;
|
2010-11-11 21:01:07 +01:00
|
|
|
}
|
|
|
|
static inline void elapsed_time_in_useconds(cmph_uint64 * elapsed_time)
|
|
|
|
{
|
|
|
|
struct timeval e_time;
|
|
|
|
if (gettimeofday(&e_time, NULL) < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*elapsed_time = (cmph_uint64)(e_time.tv_sec*1000000 + e_time.tv_usec);
|
|
|
|
}
|
2018-12-20 01:00:00 +01:00
|
|
|
static inline void dummy_elapsed_time_in_useconds(cmph_uint64 * elapsed_time)
|
2010-11-11 21:01:07 +01:00
|
|
|
{
|
2018-12-20 01:00:00 +01:00
|
|
|
(void) elapsed_time;
|
2010-11-11 21:01:07 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CMPH_TIMING
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define ELAPSED_TIME_IN_SECONDS elapsed_time_in_seconds
|
|
|
|
#define ELAPSED_TIME_IN_uSECONDS elapsed_time_in_useconds
|
|
|
|
#else
|
|
|
|
#define ELAPSED_TIME_IN_SECONDS dummy_elapsed_time_in_seconds
|
|
|
|
#define ELAPSED_TIME_IN_uSECONDS dummy_elapsed_time_in_useconds
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define ELAPSED_TIME_IN_SECONDS
|
|
|
|
#define ELAPSED_TIME_IN_uSECONDS
|
|
|
|
#else
|
|
|
|
#define ELAPSED_TIME_IN_SECONDS dummy_elapsed_time_in_seconds
|
|
|
|
#define ELAPSED_TIME_IN_uSECONDS dummy_elapsed_time_in_useconds
|
|
|
|
#endif
|
|
|
|
#endif
|