![]() |
Mads
Multi-Agent Distributed System
|
Running window statistics for execution time samples. More...
#include <execution_time_window_stats.hpp>
Public Member Functions | |
| ExecutionTimeWindowStats (std::size_t window_width=100) | |
| Construct a statistics window with a maximum number of samples. | |
| void | tic () |
| Mark the start time of the next measured interval. | |
| double | toc () |
| Mark the stop time, compute elapsed time, and append it. | |
| void | set_window_width (std::size_t window_width) |
| Set the running window width at runtime. | |
| std::size_t | window_width () const |
| Get the current configured window width. | |
| std::size_t | size () const |
| Get the number of currently stored samples. | |
| double | average_ms () const |
| Get the arithmetic mean of stored samples. | |
| double | stddev_ms () const |
| Get the population standard deviation of stored samples. | |
| void | clear () |
| Clear all stored samples and reset timing state. | |
Running window statistics for execution time samples.
This header-only utility stores the latest execution durations (in milliseconds) up to a configurable window size and provides:
average_ms())stddev_ms())Typical usage:
Definition at line 38 of file execution_time_window_stats.hpp.
|
inlineexplicit |
Construct a statistics window with a maximum number of samples.
| window_width | Maximum number of latest samples retained. |
Definition at line 45 of file execution_time_window_stats.hpp.
|
inline |
Get the arithmetic mean of stored samples.
0.0 when empty. Definition at line 111 of file execution_time_window_stats.hpp.
|
inline |
Clear all stored samples and reset timing state.
Definition at line 141 of file execution_time_window_stats.hpp.
|
inline |
Set the running window width at runtime.
If reduced, the oldest samples are dropped immediately. If increased, existing samples are preserved.
| window_width | New maximum number of retained samples. |
Definition at line 87 of file execution_time_window_stats.hpp.
References window_width().
|
inline |
Get the number of currently stored samples.
Definition at line 104 of file execution_time_window_stats.hpp.
|
inline |
Get the population standard deviation of stored samples.
Uses:
![\[
\sigma = \sqrt{E[x^2] - E[x]^2}
\]](form_0.png)
0.0 when empty. Definition at line 128 of file execution_time_window_stats.hpp.
|
inline |
Mark the start time of the next measured interval.
Call tic() before the code section you want to time, then call toc() to store the elapsed duration.
Definition at line 54 of file execution_time_window_stats.hpp.
|
inline |
Mark the stop time, compute elapsed time, and append it.
If tic() was not called, this method returns 0.0 and does not append any sample.
Definition at line 67 of file execution_time_window_stats.hpp.
|
inline |
Get the current configured window width.
Definition at line 97 of file execution_time_window_stats.hpp.
Referenced by set_window_width().