Timer class to measure time.
More...
#include <lf/base/timer.h>
|
| struct | cpu_times |
| | Packages the elapsed wall clock time, user process CPU time, and system process CPU time. More...
|
| |
|
| | Timer (bool start=true) noexcept |
| | Construct a new timer and optionally start it immediately.
|
| |
| bool | IsStopped () const noexcept |
| | Is the timer currently stopped?
|
| |
| cpu_times | Elapsed () const noexcept |
| | Elapsed time since timer start, doesn't stop the timer.
|
| |
| std::string | Format (std::string_view format=kDefaultFormat) const |
| | Return the number of elapsed seconds of the wall clock time, user time and system time as a formatted string.
|
| |
| void | Start () noexcept |
| | (Re)starts the timer, i.e. the timer starts counting from 0 when this method is called.
|
| |
| void | Stop () noexcept |
| | stop the timer, stop counting the elapsed time.
|
| |
| void | Resume () noexcept |
| | Resume the timer, i.e. start counting from where we stopped the last time.
|
| |
Timer class to measure time.
- Note
- This class is very similar to the boost::cpu_timer class.
- See also
- AutoTimer
-
boost::cpu_timer
Definition at line 64 of file timer.h.
◆ Timer()
| lf::base::Timer::Timer |
( |
bool | start = true | ) |
|
|
inlineexplicitnoexcept |
Construct a new timer and optionally start it immediately.
- Parameters
-
| start | If set to true, the timer will start immediately. Otherwise it will stay in status stopped. |
Definition at line 101 of file timer.h.
References is_stopped_, Start(), and times_.
◆ Elapsed()
◆ Format()
| std::string lf::base::Timer::Format |
( |
std::string_view | format = kDefaultFormat | ) |
const |
|
nodiscard |
Return the number of elapsed seconds of the wall clock time, user time and system time as a formatted string.
- Parameters
-
| format | The fmt format string that is used to format the output. See below for possible fmt arguments. |
- Returns
- The formatted string
format named arguments:
The following named arguments can appear in the format parameter:
Definition at line 100 of file timer.cc.
References times_.
◆ IsStopped()
| bool lf::base::Timer::IsStopped |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
◆ Resume()
| void lf::base::Timer::Resume |
( |
| ) |
|
|
noexcept |
◆ Start()
| void lf::base::Timer::Start |
( |
| ) |
|
|
noexcept |
◆ Stop()
| void lf::base::Timer::Stop |
( |
| ) |
|
|
noexcept |
◆ is_stopped_
| bool lf::base::Timer::is_stopped_ |
|
private |
◆ kDefaultFormat
| std::string lf::base::Timer::kDefaultFormat |
|
inlinestatic |
Initial value:=
"{w:.6}s wall, {u:.6}s user + {s:.6}s system = {t:.6}s CPU ({p:.3}%)"
Default format string that is used by Format()
Definition at line 164 of file timer.h.
◆ times_
The documentation for this class was generated from the following files:
- /home/runner/work/lehrfempp/lehrfempp/lib/lf/base/timer.h
- /home/runner/work/lehrfempp/lehrfempp/lib/lf/base/timer.cc