summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-21 13:36:40 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-21 13:41:36 +0100
commit9dfcd95cd776ec104348137594991813fd597b4e (patch)
treee43b7204d7e189839caa87e655e9d459126df404 /Kernel
parent0114c61cf1699f6225b6d7a05a1972425fc74557 (diff)
downloadserenity-9dfcd95cd776ec104348137594991813fd597b4e.zip
Use 64-bit integers inside Stopwatch to enable longer timings.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/i386.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/Kernel/i386.h b/Kernel/i386.h
index 4dc56620d4..9b2b3447d4 100644
--- a/Kernel/i386.h
+++ b/Kernel/i386.h
@@ -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;
};