TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec::Timer< Duration > Class Template Reference

A simple timer for measuring elapsed time. More...

#include <tec_utils.hpp>

Public Member Functions

 Timer ()
 Constructs and starts a timer.
 
void start ()
 Starts or restarts the timer.
 
Duration stop ()
 Stops the timer and returns the elapsed time.
 

Detailed Description

template<typename Duration = MilliSec>
class tec::Timer< Duration >

A simple timer for measuring elapsed time.

Measures the time elapsed between start and stop calls using a monotonic clock.

Template Parameters
DurationThe duration type for measurements (defaults to MilliSec).

Constructor & Destructor Documentation

◆ Timer()

template<typename Duration = MilliSec>
tec::Timer< Duration >::Timer ( )
inline

Constructs and starts a timer.

Initializes the timer and immediately starts it by recording the current time.

Member Function Documentation

◆ start()

template<typename Duration = MilliSec>
void tec::Timer< Duration >::start ( )
inline

Starts or restarts the timer.

Records the current time as the timer's start point.

◆ stop()

template<typename Duration = MilliSec>
Duration tec::Timer< Duration >::stop ( )
inline

Stops the timer and returns the elapsed time.

Calculates the time elapsed since the last start() call.

Returns
Duration The elapsed time since the timer was started.

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