Class Timer

Inheritance Relationships

Derived Types

Class Documentation

class Timer

A timer for running time measurements.

Subclassed by Aux::LoggingTimer, Aux::StartedTimer

Public Types

using my_steady_clock = std::chrono::steady_clock

Public Functions

Timer() = default
my_steady_clock::time_point start() noexcept

Start the clock. Returns the time at which the instance was started.

my_steady_clock::time_point stop() noexcept

Stops the clock permanently for the instance of the Timer. Returns the time at which the instance was stopped.

std::chrono::duration<uint64_t, std::milli> elapsed() const noexcept

Returns a chrono::duration since the Timer was started. If stop() was called, the duration is between the start() and stop() calls is returned.

uint64_t elapsedMilliseconds() const noexcept

Returns the number of milliseconds since the Timer was started. If stop() was called, the duration is between the start() and stop() calls is returned.

uint64_t elapsedMicroseconds() const noexcept

Returns the number of microseconds since the Timer was started. If stop() was called, the duration is between the start() and stop() calls is returned.

uint64_t elapsedNanoseconds() const noexcept

Returns the number of nanoseconds since the Timer was started. If stop() was called, the duration is between the start() and stop() calls is returned.

my_steady_clock::time_point startTime() const noexcept

Returns the time at which the instance was started.

my_steady_clock::time_point stopTime() const noexcept

Returns the time at which the instance was stopped.

std::string elapsedTag() const

Returns a human-readable representation including the elapsed time and unit.

Protected Functions

my_steady_clock::time_point stopTimeOrNow() const noexcept

If running returns now, otherwise the stop time.

Protected Attributes

bool running = {false}

true if timer has been started and not stopped after that

my_steady_clock::time_point started

time at which timer has been started

my_steady_clock::time_point stopped

time at which timer has been stopped