00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Timer.h"
00013 using namespace OpenCAL::Utils;
00014
00015 #ifndef WIN32 // Only in linux
00016 #include <sys/time.h>
00017 #include <unistd.h>
00018 #endif // WIN32
00019
00020 using namespace std;
00021
00022
00023
00024
00025
00026
00027 Timer::Timer()
00028 {
00029 }
00030
00031 Timer::~Timer()
00032 {
00033 }
00034
00035
00036
00037
00038
00039
00040 unsigned int Timer::getCurrentTime()
00041 {
00042 #ifdef WIN32 // Only in windows
00043 return GetTickCount();
00044 #else // Linux
00045 struct timeval currentTime;
00046 gettimeofday(¤tTime, 0);
00047 return currentTime.tv_sec * 1000 + currentTime.tv_usec / 1000;
00048 #endif // WIN32
00049 }
00050
00051 void Timer::wait(unsigned int milliSeconds)
00052 {
00053 #ifdef WIN32 // Only in windows
00054 Sleep(milliSeconds);
00055 #else // Linux
00056 usleep(milliSeconds * 1000);
00057 #endif // WIN32
00058 }