|
Squid Web Cache v8/master
|
#include <Stopwatch.h>
Public Types | |
| using | Clock = std::chrono::steady_clock |
| the underlying time measuring mechanism | |
Public Member Functions | |
| Stopwatch () | |
| bool | running () const |
| whether we are currently measuring time (i.e. between resume() and pause()) | |
| bool | ran () const |
| whether we ever measured time (i.e. resume() has been called) | |
| Clock::duration | total () const |
| void | resume () |
| void | pause () |
| ends the current measurement period if needed; requires prior resume() | |
Private Attributes | |
| Clock::time_point | runStart_ |
| when the current period was initiated | |
| Clock::duration | subtotal_ |
| the sum of all finished periods | |
| uint64_t | resumes_ = 0 |
| the total number of resume() calls | |
| uint64_t | pauses_ = 0 |
| the total number of pause() calls | |
Quickly accumulates related real-time (a.k.a. "physical time" or "wall clock") periods. Continues to run if the caller is blocked on a system call. Usually suitable for measuring CPU overheads of non-sleeping code sequences.
Definition at line 18 of file Stopwatch.h.
| using Stopwatch::Clock = std::chrono::steady_clock |
Definition at line 35 of file Stopwatch.h.
| Stopwatch::Stopwatch | ( | ) |
Definition at line 16 of file Stopwatch.cc.
| void Stopwatch::pause | ( | ) |
|
inline |
Definition at line 43 of file Stopwatch.h.
References resumes_.
Referenced by Format::Format::assemble().
| void Stopwatch::resume | ( | ) |
(re)starts or continues the current measurement period; each resume() call must be paired with a dedicated future pause() call
Definition at line 31 of file Stopwatch.cc.
References debugs, resumes_, running(), runStart_, and subtotal_.
Referenced by PeeringActivityTimer::PeeringActivityTimer(), CodeContext::Entering(), and main().
|
inline |
| Stopwatch::Clock::duration Stopwatch::total | ( | ) | const |
the sum of all measurement period durations (or zero) includes the current measurement period, if any
Definition at line 22 of file Stopwatch.cc.
References running(), runStart_, and subtotal_.
Referenced by Format::Format::assemble(), and main().
|
private |
Definition at line 63 of file Stopwatch.h.
|
private |
|
private |
Definition at line 58 of file Stopwatch.h.
|
private |
Definition at line 60 of file Stopwatch.h.