diff options
| author | Stefan Boberg <[email protected]> | 2021-09-29 23:04:22 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-29 23:04:22 +0200 |
| commit | a8731fea7bff836f83b8bd82d47f14a0067ad5fe (patch) | |
| tree | f4fc1fd0b06a70bd76bafaa6b0e6398fc2be46f3 /zencore/include | |
| parent | thread: Marked some members noexcept and [[nodiscard]] (diff) | |
| download | zen-a8731fea7bff836f83b8bd82d47f14a0067ad5fe.tar.xz zen-a8731fea7bff836f83b8bd82d47f14a0067ad5fe.zip | |
timer: cleaned up Stopwatch, removed GetCpuTimerValue
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/timer.h | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/zencore/include/zencore/timer.h b/zencore/include/zencore/timer.h index eb284eaee..c0f6e20ae 100644 --- a/zencore/include/zencore/timer.h +++ b/zencore/include/zencore/timer.h @@ -23,25 +23,16 @@ ZENCORE_API uint64_t GetHifreqTimerFrequencySafe(); // May be used during stati class Stopwatch { public: - Stopwatch() : m_StartValue(GetHifreqTimerValue()) {} + inline Stopwatch() : m_StartValue(GetHifreqTimerValue()) {} - inline uint64_t getElapsedTimeMs() { return (GetHifreqTimerValue() - m_StartValue) * 1000 / GetHifreqTimerFrequency(); } - - inline void reset() { m_StartValue = GetHifreqTimerValue(); } + inline uint64_t GetElapsedTimeMs() { return (GetHifreqTimerValue() - m_StartValue) * 1'000 / GetHifreqTimerFrequency(); } + inline uint64_t GetElapsedTimeUs() { return (GetHifreqTimerValue() - m_StartValue) * 1'000'000 / GetHifreqTimerFrequency(); } + inline void Reset() { m_StartValue = GetHifreqTimerValue(); } private: uint64_t m_StartValue; }; -// CPU timers - -inline uint64_t -GetCpuTimerValue() -{ - unsigned int foo; - return __rdtscp(&foo); -} - void timer_forcelink(); // internal } // namespace zen |