Class timer#

Class Documentation#

class timer#

Public Functions

inline explicit timer(const std::string &name = std::string("main"))#

Constructor - starts timer with optional name.

Note

Prints “Starting <name>” to stdout

Parameters:

name – Descriptive name for this timer instance (default: “main”)

inline ~timer()#

Destructor - prints elapsed time to stdout.

Automatically called when timer goes out of scope. Prints final elapsed time in seconds.

inline void reset()#

Reset the start time to current moment.

Useful for measuring intermediate segments of longer code blocks or repeating measurements without creating new timer objects.

inline double getDuration()#

Get elapsed duration in seconds since construction/last reset().

Note

Does not reset the timer; use reset() to restart

Note

Uses high_resolution_clock for maximum precision

Returns:

Elapsed time in seconds as double (fractional seconds supported)