Merge pull request #225 from mstorsjo/simplify-ifdefs

Simplify ifdefs in measure_time.h
This commit is contained in:
volvet 2014-01-27 00:14:44 -08:00
commit 33fe2b5883
2 changed files with 7 additions and 28 deletions

View File

@ -42,17 +42,14 @@
#include <stdlib.h>
#if !(defined(_MSC_VER) || defined(__MINGW32__))
#ifndef _WIN32
#include <sys/time.h>
#else
#include "typedefs.h"
//#include <sys/types.h>
#include <windows.h>
#include <sys/timeb.h>
#endif
#include <time.h>
#if defined(_WIN32)
#include <windows.h>
#endif//#if _WIN32
#ifdef __cplusplus
extern "C" {
@ -65,13 +62,12 @@ extern "C" {
*/
int64_t WelsTime (void_t) {
#if !(defined(_MSC_VER) || defined(__MINGW32__))
#ifndef _WIN32
struct timeval tv_date;
gettimeofday (&tv_date, NULL);
return ((int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec);
#else
#if defined (_WIN32)
static int64_t iMtimeFreq = 0;
int64_t iMtimeCur = 0;
int64_t iResult = 0;
@ -83,13 +79,7 @@ int64_t WelsTime (void_t) {
QueryPerformanceCounter ((LARGE_INTEGER*)&iMtimeCur);
iResult = (int64_t) ((double)iMtimeCur * 1e6 / (double)iMtimeFreq + 0.5);
return iResult;
#else
struct _timeb sTime;
_ftime (&sTime);
return ((int64_t)sTime.time * (1000) + (int64_t)sTime.millitm) * (1000);
#endif//#if _WIN32
#endif//!(defined(_MSC_VER) || defined(__MINGW32__))
#endif//WIN32
}
#ifdef __cplusplus

View File

@ -42,18 +42,14 @@
#include <stdlib.h>
#if !(defined(_MSC_VER) || defined(__MINGW32__))
#ifndef _WIN32
#include <sys/time.h>
#else
#include "typedefs.h"
//#include <sys/types.h>
#include <windows.h>
#include <sys/timeb.h>
#endif
#include <time.h>
#if defined(_WIN32)
#include <windows.h>
//#include <mmsystem.h> // need static lib winmm.lib for link for such windows 95/98 mm timer
#endif//#if _WIN32
/*!
* \brief time cost measure utilization
@ -62,13 +58,12 @@
*/
static inline int64_t WelsTime() {
#if !(defined(_MSC_VER) || defined(__MINGW32__))
#ifndef _WIN32
struct timeval tv_date;
gettimeofday (&tv_date, NULL);
return ((int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec);
#else
#if defined (_WIN32)
static int64_t iMeasureTimeFreq = 0;
// static BOOL_T support_high_resolution_perf_flag = TRUE;
int64_t iMeasureTimeCur = 0;
@ -94,13 +89,7 @@ iResult = (int64_t) ((double)iMeasureTimeCur * 1e6 / (double)iMeasureTimeFreq +
// }
return iResult;
#else
struct _timeb tb;
_ftime (&tb);
return ((int64_t)tb.time * (1000) + (int64_t)tb.millitm) * (1000);
#endif//#if _WIN32
#endif//!(defined(_MSC_VER) || defined(__MINGW32__))
}
#endif//WELS_TIME_COST_MEASURE_UTIL_H__