Class Timer#

Class Documentation#

class Timer#

A timer class that can be used to measure a multitude of things. The timer can be started, stopped and reset, and can, optionally, output the time between construction and destruction to the console.

Public Functions

inline explicit Timer(std::string name = "")#

Create a new timer with a given name

Parameters
  • name – The name of the timer

  • printOnDestruct – Whether to print the time between construction and destruction

Timer(const Timer&) = default#
Timer(Timer&&) = default#
Timer &operator=(const Timer&) = default#
Timer &operator=(Timer&&) = default#
template<size_t scale = time::second>
inline Timer &setTargetTime(double time)#
inline void start()#

Start the timer.

inline void stop()#

Stop the timer.

inline void reset()#

Reset the timer.

template<int64_t scale = time::second>
inline double elapsed() const#

Get the elapsed time in a given unit

Template Parameters

scale – The unit to return the time in

Returns

The elapsed time in the given unit

template<int64_t scale = time::second>
inline double average() const#

Get the average time in a given unit

Template Parameters

scale – The unit to return the time in

Returns

The average time in the given unit

inline bool isRunning()#
template<typename T, typename Char, typename Ctx>
inline void str(const fmt::formatter<T, Char> &formatter, Ctx &ctx) const#

Print the current elapsed time of the timer.