42 #include <visp3/core/vpDebug.h> 43 #include <visp3/core/vpTime.h> 53 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX 61 #ifndef DOXYGEN_SHOULD_SKIP_THIS 73 double minTimeForUsleepCall = 4;
92 LARGE_INTEGER time, frequency;
93 QueryPerformanceFrequency(&frequency);
94 if (frequency.QuadPart == 0) {
95 return (timeGetTime());
97 QueryPerformanceCounter(&time);
98 return (
double)(1000.0 * time.QuadPart / frequency.QuadPart);
103 #elif !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX 105 gettimeofday(&tp, 0);
106 return (1000.0 * tp.tv_sec + tp.tv_usec / 1000.0);
119 LARGE_INTEGER time, frequency;
120 QueryPerformanceFrequency(&frequency);
121 if (frequency.QuadPart == 0) {
122 return (timeGetTime());
124 QueryPerformanceCounter(&time);
125 return (
double)(1000000.0 * time.QuadPart / frequency.QuadPart);
130 #elif !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX 132 gettimeofday(&tp, 0);
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((useconds_t)((timeToWait - vpTime::minTimeForUsleepCall) * 1000));
167 timeToWait = t0 + t - timeCurrent;
169 }
while (timeToWait > 0.);
172 #elif defined(_WIN32) 173 #if !defined(WINRT_8_0) 174 if (timeToWait > vpTime::minTimeForUsleepCall) {
175 Sleep((DWORD)(timeToWait - vpTime::minTimeForUsleepCall));
180 timeToWait = t0 + t - timeCurrent;
182 }
while (timeToWait > 0.);
187 "vpTime::wait() is not implemented on Windows Phone 8.0"));
204 double timeToWait = t;
206 if (timeToWait <= 0.)
209 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX 211 if (timeToWait > vpTime::minTimeForUsleepCall) {
212 usleep((useconds_t)((timeToWait - vpTime::minTimeForUsleepCall) * 1000));
217 timeToWait = t0 + t - timeCurrent;
219 }
while (timeToWait > 0.);
222 #elif defined(_WIN32) 223 #if !defined(WINRT_8_0) 225 if (timeToWait > vpTime::minTimeForUsleepCall) {
226 Sleep((DWORD)(timeToWait - vpTime::minTimeForUsleepCall));
231 timeToWait = t0 + t - timeCurrent;
233 }
while (timeToWait > 0.);
238 "vpTime::wait() is not implemented on Windows Phone 8.0"));
260 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX 261 usleep((useconds_t)(t * 1000));
262 #elif defined(_WIN32) 263 #if !defined(WINRT_8_0) 267 "vpTime::sleepMs() is not implemented on Windows Phone 8.0"));
352 timeinfo = localtime(&rawtime);
354 strftime(buffer, 80, format.c_str(), timeinfo);
355 std::string str(buffer);
360 #ifndef DOXYGEN_SHOULD_SKIP_THIS VISP_EXPORT int wait(double t0, double t)
Time management and measurement.
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()