mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:47:34 +00:00
Use 64-bit integers inside Stopwatch to enable longer timings.
This commit is contained in:
parent
0114c61cf1
commit
9dfcd95cd7
5 changed files with 155 additions and 25 deletions
|
@ -269,27 +269,29 @@ inline void read_tsc(dword& lsw, dword& msw)
|
|||
}
|
||||
|
||||
struct Stopwatch {
|
||||
union SplitQword {
|
||||
struct {
|
||||
uint32_t lsw;
|
||||
uint32_t msw;
|
||||
};
|
||||
uint64_t qw { 0 };
|
||||
};
|
||||
public:
|
||||
Stopwatch(const char* name)
|
||||
: m_name(name)
|
||||
{
|
||||
read_tsc(m_start_lsw, m_start_msw);
|
||||
read_tsc(m_start.lsw, m_start.msw);
|
||||
}
|
||||
|
||||
~Stopwatch()
|
||||
{
|
||||
dword end_lsw;
|
||||
dword end_msw;
|
||||
read_tsc(end_lsw, end_msw);
|
||||
if (m_start_msw != end_msw) {
|
||||
dbgprintf("stopwatch: differing msw, no result for %s\n", m_name);
|
||||
}
|
||||
dword diff = end_lsw - m_start_lsw;
|
||||
dbgprintf("Stopwatch(%s): %u ticks\n", m_name, diff);
|
||||
SplitQword end;
|
||||
read_tsc(end.lsw, end.msw);
|
||||
uint64_t diff = end.qw - m_start.qw;
|
||||
dbgprintf("Stopwatch(%s): %q ticks\n", m_name, diff);
|
||||
}
|
||||
|
||||
private:
|
||||
const char* m_name { nullptr };
|
||||
dword m_start_lsw { 0 };
|
||||
dword m_start_msw { 0 };
|
||||
SplitQword m_start;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue