iceberg-cpp
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
iceberg::Timer Class Referenceabstract

Abstract timer for measuring operation durations. More...

#include <timer.h>

Inheritance diagram for iceberg::Timer:
iceberg::DefaultTimer

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< TimerNoop ()
 Return a shared no-op timer singleton.
 

Detailed Description

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.

Member Function Documentation

◆ Count()

virtual int64_t iceberg::Timer::Count ( ) const
pure virtual

Number of timing recordings made so far.

Implemented in iceberg::DefaultTimer.

◆ Record()

virtual void iceberg::Timer::Record ( std::chrono::nanoseconds  duration)
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.

◆ Start()

Timer::Timed iceberg::Timer::Start ( )

Start timing and return a RAII Timed guard.

The elapsed duration is recorded into this timer when the Timed guard is destroyed or Stop() is called. The caller must ensure this timer outlives the returned guard.

◆ TotalDuration()

virtual std::chrono::nanoseconds iceberg::Timer::TotalDuration ( ) const
pure virtual

Total accumulated duration across all recordings.

Implemented in iceberg::DefaultTimer.

◆ Unit()

virtual std::string_view iceberg::Timer::Unit ( ) const
inlinevirtual

Return the time unit used by this timer.

Reimplemented in iceberg::DefaultTimer.


The documentation for this class was generated from the following files: