RAII stopwatch using a selectable clock policy. More...
#include <mxvk/include/mxvk/mxvk_stopwatch.hpp>
Public Member Functions | |
| void | Echo (std::string_view name) const |
| Print the interval recorded by the clock policy. | |
| StopWatch & | operator= (const StopWatch &)=delete |
| Stopwatches cannot be copy-assigned. | |
| StopWatch & | operator= (StopWatch &&)=delete |
| Stopwatches cannot be move-assigned. | |
| void | Start (std::string_view name) |
| Start a new timed interval. | |
| void | Stop () |
| Stop the current interval and print its duration. | |
| StopWatch (const StopWatch &)=delete | |
| Stopwatches cannot be copied. | |
| StopWatch (std::string_view name) | |
| Construct and immediately start a stopwatch. | |
| StopWatch (StopWatch &&)=delete | |
| Stopwatches cannot be moved. | |
| unsigned long | TimePassed () const |
| Query the time elapsed since the most recent Start(). | |
| ~StopWatch () | |
| Stop and print the timer if it is still running. | |
RAII stopwatch using a selectable clock policy.
Construction starts the timer immediately. Stop() prints the result and is safe to call more than once. If the stopwatch is still running when it is destroyed, the destructor stops it and prints the result automatically.
| T | Clock policy satisfying ClockPolicy. |
\par Note:
The stopwatch stores its name as a std::string_view. The referenced string must remain valid for the lifetime of the stopwatch.
Definition at line 133 of file mxvk_stopwatch.hpp.
|
inlineexplicit |
Construct and immediately start a stopwatch.
| name | Descriptive name printed with the timing result. |
Definition at line 139 of file mxvk_stopwatch.hpp.
|
inline |
Stop and print the timer if it is still running.
Definition at line 144 of file mxvk_stopwatch.hpp.
|
delete |
Stopwatches cannot be copied.
|
delete |
Stopwatches cannot be moved.
|
inline |
Print the interval recorded by the clock policy.
| name | Descriptive name shown with the timing result. |
Definition at line 188 of file mxvk_stopwatch.hpp.
|
delete |
Stopwatches cannot be copy-assigned.
|
delete |
Stopwatches cannot be move-assigned.
|
inline |
Start a new timed interval.
| name | Descriptive name printed with the timing result. |
Calling this function restarts the stopwatch and replaces its name.
Definition at line 165 of file mxvk_stopwatch.hpp.
|
inline |
Stop the current interval and print its duration.
Repeated calls have no effect until Start() begins another interval.
Definition at line 176 of file mxvk_stopwatch.hpp.
|
inline |
Query the time elapsed since the most recent Start().
SteadyClockPolicy returns milliseconds, while HighResolutionClockPolicy returns nanoseconds.
Definition at line 199 of file mxvk_stopwatch.hpp.