RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Time::Timer Class Reference

Stopwatch that can be stopped and resumed, based on a steady clock. More...

#include <RST/time/Timer.hpp>

Public Types

using Clock = std::chrono::steady_clock
 
using Duration = Clock::duration
 

Public Member Functions

 Timer () noexcept=default
 
void start () noexcept
 Starts from zero.
 
void stop () noexcept
 Pauses, keeping the elapsed time.
 
void resume () noexcept
 Continues after stop().
 
void reset () noexcept
 Stops and clears the elapsed time.
 
Duration restart () noexcept
 Returns the elapsed time and starts again from zero.
 
bool isRunning () const noexcept
 
Duration elapsed () const noexcept
 Total running time.
 
template<typename T = double>
T getElapsedSeconds () const noexcept
 Elapsed time in seconds; the Ms, Us and Ns variants use milli-, micro- and nanoseconds.
 
template<typename T = double>
T getElapsedMs () const noexcept
 
template<typename T = double>
T getElapsedUs () const noexcept
 
template<typename T = double>
T getElapsedNs () const noexcept
 

Static Public Member Functions

static Timer startNew () noexcept
 Returns a running timer.
 

Detailed Description

Stopwatch that can be stopped and resumed, based on a steady clock.

Examples
system.cpp.

Member Typedef Documentation

◆ Clock

using RST::Time::Timer::Clock = std::chrono::steady_clock

◆ Duration

using RST::Time::Timer::Duration = Clock::duration

Constructor & Destructor Documentation

◆ Timer()

RST::Time::Timer::Timer ( )
defaultnoexcept

Member Function Documentation

◆ startNew()

static Timer RST::Time::Timer::startNew ( )
inlinestaticnoexcept

Returns a running timer.

Examples
system.cpp.

◆ start()

void RST::Time::Timer::start ( )
inlinenoexcept

Starts from zero.

◆ stop()

void RST::Time::Timer::stop ( )
inlinenoexcept

Pauses, keeping the elapsed time.

◆ resume()

void RST::Time::Timer::resume ( )
inlinenoexcept

Continues after stop().

◆ reset()

void RST::Time::Timer::reset ( )
inlinenoexcept

Stops and clears the elapsed time.

◆ restart()

Duration RST::Time::Timer::restart ( )
inlinenoexcept

Returns the elapsed time and starts again from zero.

◆ isRunning()

bool RST::Time::Timer::isRunning ( ) const
inlinenoexcept

◆ elapsed()

Duration RST::Time::Timer::elapsed ( ) const
inlinenoexcept

Total running time.

◆ getElapsedSeconds()

template<typename T = double>
T RST::Time::Timer::getElapsedSeconds ( ) const
inlinenoexcept

Elapsed time in seconds; the Ms, Us and Ns variants use milli-, micro- and nanoseconds.

◆ getElapsedMs()

template<typename T = double>
T RST::Time::Timer::getElapsedMs ( ) const
inlinenoexcept
Examples
system.cpp.

◆ getElapsedUs()

template<typename T = double>
T RST::Time::Timer::getElapsedUs ( ) const
inlinenoexcept

◆ getElapsedNs()

template<typename T = double>
T RST::Time::Timer::getElapsedNs ( ) const
inlinenoexcept

The documentation for this class was generated from the following file: