mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
LibCore: Expose origin timestamp of Core::ElapsedTime
This commit is contained in:
parent
97d0acc5b6
commit
62785b7872
2 changed files with 6 additions and 4 deletions
|
@ -37,8 +37,8 @@ void ElapsedTimer::start()
|
||||||
m_valid = true;
|
m_valid = true;
|
||||||
timespec now_spec;
|
timespec now_spec;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now_spec);
|
clock_gettime(CLOCK_MONOTONIC, &now_spec);
|
||||||
m_start_time.tv_sec = now_spec.tv_sec;
|
m_origin_time.tv_sec = now_spec.tv_sec;
|
||||||
m_start_time.tv_usec = now_spec.tv_nsec / 1000;
|
m_origin_time.tv_usec = now_spec.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ElapsedTimer::elapsed() const
|
int ElapsedTimer::elapsed() const
|
||||||
|
@ -50,7 +50,7 @@ int ElapsedTimer::elapsed() const
|
||||||
now.tv_sec = now_spec.tv_sec;
|
now.tv_sec = now_spec.tv_sec;
|
||||||
now.tv_usec = now_spec.tv_nsec / 1000;
|
now.tv_usec = now_spec.tv_nsec / 1000;
|
||||||
struct timeval diff;
|
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;
|
return diff.tv_sec * 1000 + diff.tv_usec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,11 @@ public:
|
||||||
void start();
|
void start();
|
||||||
int elapsed() const;
|
int elapsed() const;
|
||||||
|
|
||||||
|
const struct timeval& origin_time() const { return m_origin_time; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_valid { false };
|
bool m_valid { false };
|
||||||
struct timeval m_start_time {
|
struct timeval m_origin_time {
|
||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue