42 #include <visp3/core/vpTime.h>
43 #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;
97 LARGE_INTEGER time, frequency;
98 QueryPerformanceFrequency(&frequency);
99 if(frequency.QuadPart == 0){
100 return(timeGetTime());
103 QueryPerformanceCounter(&time);
104 return (
double)(1000.0*time.QuadPart/frequency.QuadPart);
109 #elif !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
112 return(1000.0*tp.tv_sec + tp.tv_usec/1000.0);
124 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
125 LARGE_INTEGER time, frequency;
126 QueryPerformanceFrequency(&frequency);
127 if(frequency.QuadPart == 0){
128 return(timeGetTime());
131 QueryPerformanceCounter(&time);
132 return (
double)(1000000.0*time.QuadPart/frequency.QuadPart);
134 # elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
140 return(1000000.0*tp.tv_sec + tp.tv_usec);
159 double timeCurrent, timeToWait;
162 timeToWait = t0 + t - timeCurrent;
164 if ( timeToWait <= 0. )
167 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
168 if (timeToWait > vpTime::minTimeForUsleepCall) {
169 usleep((useconds_t)((timeToWait-vpTime::minTimeForUsleepCall)*1000));
174 timeToWait = t0 + t - timeCurrent;
176 }
while (timeToWait > 0.);
179 #elif defined(_WIN32)
180 # if !defined(WINRT_8_0)
181 if (timeToWait > vpTime::minTimeForUsleepCall) {
182 Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall));
187 timeToWait = t0 + t - timeCurrent;
189 }
while (timeToWait > 0.);
210 double timeToWait = t;
212 if ( timeToWait <= 0. )
215 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
217 if (timeToWait > vpTime::minTimeForUsleepCall) {
218 usleep((useconds_t)((timeToWait-vpTime::minTimeForUsleepCall)*1000));
223 timeToWait = t0 + t - timeCurrent;
225 }
while (timeToWait > 0.);
228 #elif defined(_WIN32)
229 # if !defined(WINRT_8_0)
231 if (timeToWait > vpTime::minTimeForUsleepCall) {
232 Sleep((DWORD)(timeToWait-vpTime::minTimeForUsleepCall));
237 timeToWait = t0 + t - timeCurrent;
239 }
while (timeToWait > 0.);
268 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
269 usleep((useconds_t)(t*1000));
270 #elif defined(_WIN32)
271 # if !defined(WINRT_8_0)
353 struct tm * timeinfo;
357 timeinfo = localtime(&rawtime);
359 strftime(buffer, 80, format.c_str(), timeinfo);
360 std::string str(buffer);
365 #ifndef DOXYGEN_SHOULD_SKIP_THIS
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeSecond()
error that can be emited by ViSP classes.
VISP_EXPORT double measureTimeMs()
VISP_EXPORT std::string getDateTime(const std::string &format="%Y/%m/%d %H:%M:%S")
VISP_EXPORT void sleepMs(double t)
VISP_EXPORT double measureTimeMicros()
VISP_EXPORT double getMinTimeForUsleepCall()