mal-packet-weaver
C++20 packet serialization/deserialization library.
Loading...
Searching...
No Matches
mal_toolkit::Timer< clock > Class Template Reference

A simple timer class for measuring elapsed time using various clock types. More...

#include "timer.hpp"

Inheritance diagram for mal_toolkit::Timer< clock >:
[legend]
Collaboration diagram for mal_toolkit::Timer< clock >:
[legend]

Public Member Functions

 Timer ()
 Constructs a Timer and initializes it with the current time.
 
void reset_to_now ()
 Resets the start time to the current time.
 
void reset ()
 Resets the start time to the previously captured current time.
 
constexpr float elapsed () noexcept
 Calculates and returns the elapsed time since the timer was last reset.
 

Private Attributes

std::chrono::time_point< clock > start_
 The time point representing the start time.
 
std::chrono::time_point< clock > current_
 The time point representing the current time.
 

Detailed Description

template<class clock>
class mal_toolkit::Timer< clock >

A simple timer class for measuring elapsed time using various clock types.

This class provides the ability to measure elapsed time using different clock types (e.g., steady_clock, high_resolution_clock).

Definition at line 16 of file timer.hpp.

Constructor & Destructor Documentation

◆ Timer()

template<class clock >
mal_toolkit::Timer< clock >::Timer ( )
inline

Constructs a Timer and initializes it with the current time.

Definition at line 22 of file timer.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ elapsed()

template<class clock >
float mal_toolkit::Timer< clock >::elapsed ( )
inlineconstexprnoexcept

Calculates and returns the elapsed time since the timer was last reset.

Returns
The elapsed time in seconds.

Definition at line 43 of file timer.hpp.

Here is the caller graph for this function:

◆ reset()

template<class clock >
void mal_toolkit::Timer< clock >::reset ( )
inline

Resets the start time to the previously captured current time.

Definition at line 36 of file timer.hpp.

Here is the caller graph for this function:

◆ reset_to_now()

template<class clock >
void mal_toolkit::Timer< clock >::reset_to_now ( )
inline

Resets the start time to the current time.

Definition at line 31 of file timer.hpp.

Member Data Documentation

◆ current_

template<class clock >
std::chrono::time_point<clock> mal_toolkit::Timer< clock >::current_
private

The time point representing the current time.

Definition at line 51 of file timer.hpp.

◆ start_

template<class clock >
std::chrono::time_point<clock> mal_toolkit::Timer< clock >::start_
private

The time point representing the start time.

Definition at line 50 of file timer.hpp.


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