1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:18:12 +00:00

LibCore: Expose origin timestamp of Core::ElapsedTime

This commit is contained in:
Andreas Kling 2020-09-29 18:22:53 +02:00
parent 97d0acc5b6
commit 62785b7872
2 changed files with 6 additions and 4 deletions

View file

@ -37,8 +37,8 @@ void ElapsedTimer::start()
m_valid = true;
timespec now_spec;
clock_gettime(CLOCK_MONOTONIC, &now_spec);
m_start_time.tv_sec = now_spec.tv_sec;
m_start_time.tv_usec = now_spec.tv_nsec / 1000;
m_origin_time.tv_sec = now_spec.tv_sec;
m_origin_time.tv_usec = now_spec.tv_nsec / 1000;
}
int ElapsedTimer::elapsed() const
@ -50,7 +50,7 @@ int ElapsedTimer::elapsed() const
now.tv_sec = now_spec.tv_sec;
now.tv_usec = now_spec.tv_nsec / 1000;
struct timeval diff;
timeval_sub(now, m_start_time, diff);
timeval_sub(now, m_origin_time, diff);
return diff.tv_sec * 1000 + diff.tv_usec / 1000;
}