iceberg-cpp
Loading...
Searching...
No Matches
Public Member Functions | List of all members
iceberg::DefaultTimer Class Reference

Thread-safe timer backed by std::atomic<int64_t>. More...

#include <timer.h>

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

Public Member Functions

 DefaultTimer (TimerUnit unit=TimerUnit::kNanoseconds)
 
int64_t Count () const override
 Number of timing recordings made so far.
 
std::chrono::nanoseconds TotalDuration () const override
 Total accumulated duration across all recordings.
 
void Record (std::chrono::nanoseconds duration) override
 Record a nanosecond duration directly.
 
std::string_view Unit () const override
 Return the time unit used by this timer.
 
- Public Member Functions inherited from iceberg::Timer
template<typename Rep , typename Period >
void Record (std::chrono::duration< Rep, Period > duration)
 Record a duration of any chrono type, converting to nanoseconds.
 
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.
 

Additional Inherited Members

- Static Public Member Functions inherited from iceberg::Timer
static std::shared_ptr< TimerNoop ()
 Return a shared no-op timer singleton.
 

Detailed Description

Thread-safe timer backed by std::atomic<int64_t>.

Member Function Documentation

◆ Count()

int64_t iceberg::DefaultTimer::Count ( ) const
overridevirtual

Number of timing recordings made so far.

Implements iceberg::Timer.

◆ Record()

void iceberg::DefaultTimer::Record ( std::chrono::nanoseconds  duration)
overridevirtual

Record a nanosecond duration directly.

Use the template overload below to record any std::chrono duration type with automatic unit conversion.

Implements iceberg::Timer.

◆ TotalDuration()

std::chrono::nanoseconds iceberg::DefaultTimer::TotalDuration ( ) const
overridevirtual

Total accumulated duration across all recordings.

Implements iceberg::Timer.

◆ Unit()

std::string_view iceberg::DefaultTimer::Unit ( ) const
inlineoverridevirtual

Return the time unit used by this timer.

Reimplemented from iceberg::Timer.


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