|
iceberg-cpp
|
Abstract timer for measuring operation durations. More...
#include <timer.h>
Classes | |
| class | Timed |
| RAII guard that records elapsed time into a non-owning Timer on destruction. More... | |
Public Member Functions | |
| virtual int64_t | Count () const =0 |
| Number of timing recordings made so far. | |
| virtual std::chrono::nanoseconds | TotalDuration () const =0 |
| Total accumulated duration across all recordings. | |
| virtual void | Record (std::chrono::nanoseconds duration)=0 |
| Record a nanosecond duration directly. | |
| template<typename Rep , typename Period > | |
| void | Record (std::chrono::duration< Rep, Period > duration) |
| Record a duration of any chrono type, converting to nanoseconds. | |
| virtual std::string_view | Unit () const |
| Return the time unit used by this timer. | |
| virtual bool | IsNoop () const |
| Return true if this timer is a no-op. | |
| Timed | Start () |
| Start timing and return a RAII Timed guard. | |
| template<typename Callable > | |
| decltype(auto) | Time (Callable &&fn) |
| Execute a callable, record its wall-clock duration, and return its result. | |
Static Public Member Functions | |
| static std::shared_ptr< Timer > | Noop () |
| Return a shared no-op timer singleton. | |
Abstract timer for measuring operation durations.
Use Start() to obtain a Timed RAII guard that records the elapsed duration when it goes out of scope.
|
pure virtual |
Number of timing recordings made so far.
Implemented in iceberg::DefaultTimer.
|
pure virtual |
Record a nanosecond duration directly.
Use the template overload below to record any std::chrono duration type with automatic unit conversion.
Implemented in iceberg::DefaultTimer.
| Timer::Timed iceberg::Timer::Start | ( | ) |
|
pure virtual |
Total accumulated duration across all recordings.
Implemented in iceberg::DefaultTimer.
|
inlinevirtual |
Return the time unit used by this timer.
Reimplemented in iceberg::DefaultTimer.