mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-04-06 15:04:18 +00:00
Fix time measurement issud
This commit is contained in:
parent
ae532156c5
commit
657ef07b56
2 changed files with 7 additions and 12 deletions
|
|
@ -64,21 +64,16 @@ CStopWatch::~CStopWatch()
|
|||
|
||||
unsigned long CStopWatch::start()
|
||||
{
|
||||
::gettimeofday(&m_start, NULL);
|
||||
|
||||
return m_start.tv_usec;
|
||||
::clock_gettime(CLOCK_MONOTONIC, &m_start);
|
||||
return m_start.tv_sec;
|
||||
}
|
||||
|
||||
unsigned int CStopWatch::elapsed()
|
||||
{
|
||||
struct timeval now;
|
||||
::gettimeofday(&now, NULL);
|
||||
|
||||
unsigned int elapsed = (now.tv_sec - m_start.tv_sec) * 1000U;
|
||||
elapsed += now.tv_usec / 1000U;
|
||||
elapsed -= m_start.tv_usec / 1000U;
|
||||
|
||||
return elapsed;
|
||||
struct timespec now;
|
||||
::clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
int offset = ((now.tv_sec - m_start.tv_sec) * 1000000000UL + now.tv_nsec - m_start.tv_nsec ) / 1000000UL;
|
||||
return (unsigned int)offset;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue