mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-23 00:35:53 +08:00
Change the elapsed time calculation a little.
This commit is contained in:
@@ -72,8 +72,9 @@ unsigned int CStopWatch::elapsed()
|
|||||||
struct timeval now;
|
struct timeval now;
|
||||||
::gettimeofday(&now, NULL);
|
::gettimeofday(&now, NULL);
|
||||||
|
|
||||||
unsigned long long a = m_start.tv_sec * 1000ULL + m_start.tv_usec / 1000ULL;
|
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
||||||
unsigned long long b = now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
|
elapsed += now.tv_usec / 1000U;
|
||||||
|
elapsed -= m_start.tv_usec / 1000U;
|
||||||
|
|
||||||
return (unsigned int)(b - a);
|
return (unsigned int)(b - a);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user