Skip to content

Commit

Permalink
Refactor timers
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed Sep 13, 2018
1 parent a26ddc3 commit 3e82124
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions MAGE/Utilities/src/system/cpu_monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion MAGE/Utilities/src/system/game_timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
16 changes: 8 additions & 8 deletions MAGE/Utilities/src/system/timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -149,7 +149,7 @@ namespace mage {
(in seconds) of this timer.
*/
const std::pair< TimeIntervalSeconds, TimeIntervalSeconds >
GetTime() const noexcept;
GetTime() noexcept;

private:

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 5 additions & 9 deletions MAGE/Utilities/src/system/timer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
Expand All @@ -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.
Expand All @@ -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();

Expand Down

0 comments on commit 3e82124

Please sign in to comment.