Class Chrono

Class Documentation

class Chrono

A class providing a timer.

This class records execution wall and CPU time as well as a record of the number of times that the chronometer has been started.

Public Types

typedef std::chrono::high_resolution_clock::time_point WallTimePoint

Type of a point in time for the wall clock.

typedef std::chrono::high_resolution_clock::duration WallTimeDuration

Type of a time duration on the wall clock.

typedef std::clock_t CpuTimePoint

Type of a point in time for the CPU clock.

typedef double CpuTimeDuration

Type of a time duration on the CPU clock.

Public Functions

inline Chrono()

Default constructor of a chronometer, zeroing all of the counters.

~Chrono() = default
inline WallTimePoint wallHack() const

Returns the current time on the wall clock.

inline WallTimeDuration wallTime() const

Returns the current cumulative wall clock time.

inline void reset()

Resets all of the chronometer counters.

inline CpuTimePoint cpuHack() const

Returns the current time on the CPU clock.

inline CpuTimeDuration cpuTime() const

Returns the current cumulative CPU clock timer.

inline int ticks() const

Returns the current number of activation ticks.

inline bool running() const

Returns whether this chronometer is running.

inline void start()

Starts the timer.

Starts the clock on both the wall and CPU clocks, increments the number of activation ticks and sets the running flag.

inline void stop()

Stops the timer.

Stops both the wall and CPU clocks, updates the cumulative time for both clocks and unsets the running flag.

inline void extraCpuTime(const CpuTimeDuration &extraTime)

Adds an externally determined increment to the CPU clock.

Parameters:

extraTime – the additional duration to be added to the CPU clock.

inline void extraWallTime(const WallTimeDuration &extraTime)

Adds an externally determined increment to the wall clock.

Parameters:

extraTime – the additional duration to be added to the wall clock.

inline void extraTicks(int extraTicks)

Adds an externally determined increment to the activation count.

Parameters:

extraTicks – the additional ticks to be added to the activation count.