diff options
| author | Stefan Boberg <[email protected]> | 2021-09-30 10:37:04 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-30 10:37:04 +0200 |
| commit | 0d92f2bed096317094c9d507e2d8750dfd8c9975 (patch) | |
| tree | 03128688a53ba62f1f3540f225c460aee116d3bb | |
| parent | iobuffer: Removed AssumeOwnership constructor since we would like stronger gu... (diff) | |
| download | zen-0d92f2bed096317094c9d507e2d8750dfd8c9975.tar.xz zen-0d92f2bed096317094c9d507e2d8750dfd8c9975.zip | |
timer: Added Stopwatch::GetElapsedTIcks() and functions to convert ticks so Ms/Us
| -rw-r--r-- | zencore/include/zencore/timer.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/zencore/include/zencore/timer.h b/zencore/include/zencore/timer.h index c0f6e20ae..66a8e0215 100644 --- a/zencore/include/zencore/timer.h +++ b/zencore/include/zencore/timer.h @@ -25,10 +25,14 @@ class Stopwatch public: inline Stopwatch() : 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 uint64_t GetElapsedTimeMs() const { return (GetHifreqTimerValue() - m_StartValue) * 1'000 / GetHifreqTimerFrequency(); } + inline uint64_t GetElapsedTimeUs() const { return (GetHifreqTimerValue() - m_StartValue) * 1'000'000 / GetHifreqTimerFrequency(); } + inline uint64_t GetElapsedTicks() const { return GetHifreqTimerValue() - m_StartValue; } inline void Reset() { m_StartValue = GetHifreqTimerValue(); } + static inline uint64_t GetElapsedTimeMs(uint64_t Ticks) { return Ticks * 1'000 / GetHifreqTimerFrequency(); } + static inline uint64_t GetElapsedTimeUs(uint64_t Ticks) { return Ticks * 1'000'000 / GetHifreqTimerFrequency(); } + private: uint64_t m_StartValue; }; |