From 3e821242d71abac30fc6d58505d005c9ce694256 Mon Sep 17 00:00:00 2001 From: REDDRAGON Date: Thu, 13 Sep 2018 15:08:27 +0200 Subject: [PATCH] Refactor timers --- MAGE/Utilities/src/system/cpu_monitor.hpp | 4 ++-- MAGE/Utilities/src/system/game_timer.hpp | 2 +- MAGE/Utilities/src/system/timer.hpp | 16 ++++++++-------- MAGE/Utilities/src/system/timer.tpp | 14 +++++--------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/MAGE/Utilities/src/system/cpu_monitor.hpp b/MAGE/Utilities/src/system/cpu_monitor.hpp index 5f5f240df..9d81be95d 100644 --- a/MAGE/Utilities/src/system/cpu_monitor.hpp +++ b/MAGE/Utilities/src/system/cpu_monitor.hpp @@ -116,7 +116,7 @@ namespace mage { @return The CPU delta percentage of this CPU monitor's process. */ - F64 GetCPUDeltaPercentage() const noexcept { + F64 GetCPUDeltaPercentage() noexcept { const auto wall_time = m_wall_clock_timer.GetDeltaTime(); const auto core_time = m_core_clock_timer.GetDeltaTime(); return 100.0 * (core_time / wall_time); @@ -128,7 +128,7 @@ namespace mage { @return The total CPU delta percentage of this CPU monitor's process. */ - F64 GetTotalCPUDeltaPercentage() const noexcept { + F64 GetTotalCPUDeltaPercentage() noexcept { const auto wall_time = m_wall_clock_timer.GetTotalDeltaTime(); const auto core_time = m_core_clock_timer.GetTotalDeltaTime(); return 100.0 * (core_time / wall_time); diff --git a/MAGE/Utilities/src/system/game_timer.hpp b/MAGE/Utilities/src/system/game_timer.hpp index b36021a4e..cf7debdee 100644 --- a/MAGE/Utilities/src/system/game_timer.hpp +++ b/MAGE/Utilities/src/system/game_timer.hpp @@ -286,7 +286,7 @@ namespace mage { @return The game time of this game timer. */ - const GameTime GetTime() const noexcept { + const GameTime GetTime() noexcept { const auto wall_clock_time = m_wall_clock_timer.GetTime(); const auto core_clock_time = m_core_clock_timer.GetTime(); diff --git a/MAGE/Utilities/src/system/timer.hpp b/MAGE/Utilities/src/system/timer.hpp index e98229d46..3778bcb06 100644 --- a/MAGE/Utilities/src/system/timer.hpp +++ b/MAGE/Utilities/src/system/timer.hpp @@ -133,14 +133,14 @@ namespace mage { @return The delta time (in seconds) of this timer. */ - TimeIntervalSeconds GetDeltaTime() const noexcept; + TimeIntervalSeconds GetDeltaTime() noexcept; /** Returns the total delta time (in seconds) of this timer. @return The total delta time (in seconds) of this timer. */ - TimeIntervalSeconds GetTotalDeltaTime() const noexcept; + TimeIntervalSeconds GetTotalDeltaTime() noexcept; /** Returns the delta and total delta time (in seconds) of this timer. @@ -149,7 +149,7 @@ namespace mage { (in seconds) of this timer. */ const std::pair< TimeIntervalSeconds, TimeIntervalSeconds > - GetTime() const noexcept; + GetTime() noexcept; private: @@ -161,13 +161,13 @@ namespace mage { Resets the delta time, total delta time and last timestamp of this timer. */ - void ResetDeltaTime() const noexcept; + void ResetDeltaTime() noexcept; /** Updates the delta time, total delta time and last timestamp of this timer. */ - void UpdateDeltaTime() const noexcept; + void UpdateDeltaTime() noexcept; //--------------------------------------------------------------------- // Class Member Types @@ -196,17 +196,17 @@ namespace mage { /** The last timestamp of this timer. */ - mutable TimeStamp m_last_timestamp; + TimeStamp m_last_timestamp; /** The delta time of this timer. */ - mutable TimeInterval m_delta_time; + TimeInterval m_delta_time; /** The total delta time of this timer. */ - mutable TimeInterval m_total_delta_time; + TimeInterval m_total_delta_time; /** Flag indicating whether this timer is running. diff --git a/MAGE/Utilities/src/system/timer.tpp b/MAGE/Utilities/src/system/timer.tpp index 5235e51f6..7363effca 100644 --- a/MAGE/Utilities/src/system/timer.tpp +++ b/MAGE/Utilities/src/system/timer.tpp @@ -50,9 +50,7 @@ namespace mage { } template< typename ClockT > - inline TimeIntervalSeconds Timer< ClockT > - ::GetDeltaTime() const noexcept { - + inline TimeIntervalSeconds Timer< ClockT >::GetDeltaTime() noexcept { if (m_running) { UpdateDeltaTime(); } @@ -61,9 +59,7 @@ namespace mage { } template< typename ClockT > - inline TimeIntervalSeconds Timer< ClockT > - ::GetTotalDeltaTime() const noexcept { - + inline TimeIntervalSeconds Timer< ClockT >::GetTotalDeltaTime() noexcept { if (m_running) { UpdateDeltaTime(); } @@ -73,7 +69,7 @@ namespace mage { template< typename ClockT > inline const std::pair< TimeIntervalSeconds, TimeIntervalSeconds > - Timer< ClockT >::GetTime() const noexcept { + Timer< ClockT >::GetTime() noexcept { if (m_running) { UpdateDeltaTime(); @@ -86,7 +82,7 @@ namespace mage { } template< typename ClockT > - inline void Timer< ClockT >::ResetDeltaTime() const noexcept { + inline void Timer< ClockT >::ResetDeltaTime() noexcept { // Resets the delta time of this timer. m_delta_time = TimeInterval::zero(); // Resets the total delta time of this timer. @@ -96,7 +92,7 @@ namespace mage { } template< typename ClockT > - inline void Timer< ClockT >::UpdateDeltaTime() const noexcept { + inline void Timer< ClockT >::UpdateDeltaTime() noexcept { // Get the current timestamp of this timer. const auto current_timestamp = m_clock.now();