mal-packet-weaver
C++20 packet serialization/deserialization library.
|
A class for measuring and logging the execution time of functions. More...
#include "measurer.hpp"
Classes | |
struct | Entry |
Public Member Functions | |
Measurer (std::string_view s="Measurer", bool log_automatically=true, float time_to_flush=30, std::source_location location=std::source_location::current()) | |
Construct a Measurer object. | |
void | begin () |
Start measuring execution time. | |
float | end () |
End measurement and log the result. | |
void | log () |
Log the accumulated measurements. | |
float | avg (const size_t last_n_entries=std::numeric_limits< size_t >::max()) |
Calculate the average execution time of the last N entries. | |
float | avg_over_the_last (float seconds) |
Calculate the average execution time over a specific time interval. | |
float | avg_over_the_last_limited (const float seconds) |
Calculate the average execution time over a specific time interval with a limit. | |
uint64_t | amount_of_calls (float seconds) |
Calculate the amount of function calls within a specific time interval. | |
float | elapsed () |
Get the total elapsed time since the start of the measurement. | |
Public Attributes | |
float | time_to_flush = 30 |
Interval in seconds for automatic log flushing. | |
size_t | maximum_entries = std::numeric_limits<size_t>::max() |
Maximum number of measurement entries. | |
bool | log_automatically = true |
Determines if measurements are logged automatically. | |
Private Attributes | |
std::string | output |
The string identifier for the measurer. | |
std::vector< Entry > | entries |
A vector of measurement entries. | |
size_t | index = 0 |
The current index in the entries vector. | |
Timer< clock > | flush |
Timer for automatic log flushing. | |
Timer< clock > | measure |
Timer for measuring execution time. | |
Timer< clock > | entry_time |
Timer for tracking entry times. | |
A class for measuring and logging the execution time of functions.
clock | The clock type to use for timing (e.g., std::chrono::steady_clock). |
Definition at line 16 of file measurer.hpp.
|
inline |
Construct a Measurer object.
s | A string identifier for the measurer. |
log_automatically | Whether to log measurements automatically. |
time_to_flush | Time interval for automatic log flushing (in seconds). |
location | The source location (optional) for debug logging. |
Definition at line 37 of file measurer.hpp.
|
inline |
Calculate the amount of function calls within a specific time interval.
seconds | Time interval in seconds. |
Definition at line 165 of file measurer.hpp.
|
inline |
Calculate the average execution time of the last N entries.
last_n_entries | Number of last entries to consider. |
Definition at line 104 of file measurer.hpp.
|
inline |
Calculate the average execution time over a specific time interval.
seconds | Time interval in seconds. |
Definition at line 121 of file measurer.hpp.
|
inline |
Calculate the average execution time over a specific time interval with a limit.
seconds | Time interval in seconds. |
Definition at line 141 of file measurer.hpp.
|
inline |
Start measuring execution time.
Definition at line 54 of file measurer.hpp.
|
inline |
Get the total elapsed time since the start of the measurement.
Definition at line 184 of file measurer.hpp.
|
inline |
End measurement and log the result.
Definition at line 60 of file measurer.hpp.
|
inline |
Log the accumulated measurements.
Definition at line 75 of file measurer.hpp.
|
private |
A vector of measurement entries.
Definition at line 192 of file measurer.hpp.
|
private |
Timer for tracking entry times.
Definition at line 196 of file measurer.hpp.
|
private |
Timer for automatic log flushing.
Definition at line 194 of file measurer.hpp.
|
private |
The current index in the entries vector.
Definition at line 193 of file measurer.hpp.
bool mal_toolkit::Measurer< clock >::log_automatically = true |
Determines if measurements are logged automatically.
Definition at line 188 of file measurer.hpp.
size_t mal_toolkit::Measurer< clock >::maximum_entries = std::numeric_limits<size_t>::max() |
Maximum number of measurement entries.
Definition at line 187 of file measurer.hpp.
|
private |
Timer for measuring execution time.
Definition at line 195 of file measurer.hpp.
|
private |
The string identifier for the measurer.
Definition at line 191 of file measurer.hpp.
float mal_toolkit::Measurer< clock >::time_to_flush = 30 |
Interval in seconds for automatic log flushing.
Definition at line 186 of file measurer.hpp.