41 #include <visp3/core/vpTime.h>
42 #include <visp3/core/vpDebug.h>
55 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
56 # include <sys/time.h>
63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
75 double minTimeForUsleepCall = 4;
84 return minTimeForUsleepCall;
96 LARGE_INTEGER time, frequency;
97 QueryPerformanceFrequency(&frequency);
98 if(frequency.QuadPart == 0){
99 return(timeGetTime());
102 QueryPerformanceCounter(&time);
103 return (
double)(1000.0*time.QuadPart/frequency.QuadPart);
105 #elif !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
108 return(1000.0*tp.tv_sec + tp.tv_usec/1000.0);
120 LARGE_INTEGER time, frequency;
121 QueryPerformanceFrequency(&frequency);
122 if(frequency.QuadPart == 0){
123 return(timeGetTime());
126 QueryPerformanceCounter(&time);
127 return (
double)(1000000.0*time.QuadPart/frequency.QuadPart);
133 return(1000000.0*tp.tv_sec + tp.tv_usec);
152 double timeCurrent, timeToWait;
155 timeToWait = t0 + t - timeCurrent;
157 if ( timeToWait <= 0. )
160 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
161 if (timeToWait > vpTime::minTimeForUsleepCall) {
162 usleep((
unsigned long )((timeToWait-vpTime::minTimeForUsleepCall)*1000));
164 #elif defined(_WIN32)
165 if (timeToWait > vpTime::minTimeForUsleepCall) {
166 Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall));
172 timeToWait = t0 + t - timeCurrent;
174 }
while (timeToWait > 0.);
191 double t0, timeCurrent, timeToWait;
196 if ( timeToWait <= 0. )
199 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
200 if (timeToWait > vpTime::minTimeForUsleepCall) {
201 usleep((
unsigned long )((timeToWait-vpTime::minTimeForUsleepCall)*1000));
203 #elif defined(_WIN32)
204 if (timeToWait > vpTime::minTimeForUsleepCall) {
205 Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall));
211 timeToWait = t0 + t - timeCurrent;
213 }
while (timeToWait > 0.);
238 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
239 usleep((
unsigned long )(t*1000));
240 #elif defined(_WIN32)
245 #ifndef DOXYGEN_SHOULD_SKIP_THIS
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeSecond()
VISP_EXPORT void sleepMs(double t)
VISP_EXPORT double measureTimeMicros()
VISP_EXPORT double measureTimeMs()
VISP_EXPORT double getMinTimeForUsleepCall()