Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
BS::timer Class Reference

A utility class to measure execution time for benchmarking purposes. More...

#include <BS_thread_pool_utils.hpp>

Public Member Functions

 timer ()=default
 Construct a new timer and immediately start measuring time.
 
std::chrono::milliseconds::rep current_ms () const
 Get the number of milliseconds that have elapsed since the object was constructed or since start() was last called, but keep the timer ticking.
 
void start ()
 Start (or restart) measuring time. Note that the timer starts ticking as soon as the object is created, so this is only necessary if we want to restart the clock later.
 
void stop ()
 Stop measuring time and store the elapsed time since the object was constructed or since start() was last called.
 
std::chrono::milliseconds::rep ms () const
 Get the number of milliseconds stored when stop() was last called.
 

Private Attributes

std::chrono::time_point< std::chrono::steady_clock > start_time = std::chrono::steady_clock::now()
 The time point when measuring started.
 
std::chrono::duration< double > elapsed_time = std::chrono::duration<double>::zero()
 The duration that has elapsed between start() and stop().
 

Detailed Description

A utility class to measure execution time for benchmarking purposes.

Member Function Documentation

◆ current_ms()

std::chrono::milliseconds::rep BS::timer::current_ms ( ) const
inline

Get the number of milliseconds that have elapsed since the object was constructed or since start() was last called, but keep the timer ticking.

Returns
The number of milliseconds.
161 {
162 return (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time)).count();
163 }
std::chrono::time_point< std::chrono::steady_clock > start_time
The time point when measuring started.
Definition BS_thread_pool_utils.hpp:195

◆ start()

void BS::timer::start ( )
inline

Start (or restart) measuring time. Note that the timer starts ticking as soon as the object is created, so this is only necessary if we want to restart the clock later.

169 {
170 start_time = std::chrono::steady_clock::now();
171 }
Here is the caller graph for this function:

◆ stop()

void BS::timer::stop ( )
inline

Stop measuring time and store the elapsed time since the object was constructed or since start() was last called.

177 {
178 elapsed_time = std::chrono::steady_clock::now() - start_time;
179 }
std::chrono::duration< double > elapsed_time
The duration that has elapsed between start() and stop().
Definition BS_thread_pool_utils.hpp:200
Here is the caller graph for this function:

◆ ms()

std::chrono::milliseconds::rep BS::timer::ms ( ) const
inline

Get the number of milliseconds stored when stop() was last called.

Returns
The number of milliseconds.
187 {
188 return (std::chrono::duration_cast<std::chrono::milliseconds>(elapsed_time)).count();
189 }
Here is the caller graph for this function:

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