A utility class to measure execution time for benchmarking purposes.
More...
#include <BS_thread_pool_utils.hpp>
|
| 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.
|
|
|
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() .
|
|
A utility class to measure execution time for benchmarking purposes.
◆ 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 }
◆ stop()
Stop measuring time and store the elapsed time since the object was constructed or since start()
was last called.
177 {
179 }
std::chrono::duration< double > elapsed_time
The duration that has elapsed between start() and stop().
Definition BS_thread_pool_utils.hpp:200
◆ 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 }
The documentation for this class was generated from the following file: