Created
November 28, 2010 19:17
-
-
Save christiankakesa/719215 to your computer and use it in GitHub Desktop.
gettimeofday
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... | |
#if defined(WINXX) | |
#include <sys/timeb.h> | |
typedef struct timeval { | |
__time64_t tv_sec; | |
long tv_usec; | |
} timeval; | |
#else | |
#include <sys/time.h> | |
#endif //defined(WINXX) | |
//... | |
class Time | |
{ | |
public: | |
static unsigned long int GetTimeInMilli() | |
{ | |
unsigned long int res = 0; | |
struct timeval tim; | |
#if defined(WINXX) | |
struct _timeb timebuffer; | |
_ftime64_s(&timebuffer); | |
tim.tv_sec = timebuffer.time; | |
tim.tv_usec = timebuffer.millitm * 1000; | |
#else //Assuming linux | |
gettimeofday(&tim, NULL); | |
#endif //defined(WINXX) | |
res = tim.tv_sec * 1000 + static_cast<unsigned long int>(tim.tv_usec / 1000); | |
return res; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment