StormByte 3.0.0
C++26 foundation of the StormByte suite
Loading...
Searching...
No Matches
StormByte::Clock Class Referencefinal

Thread-safe aggregate of independently timed operation samples. More...

#include <StormByte/telemetry.hxx>

Classes

struct  Values
 Coherent snapshot of completed measurements. More...
class  Sample
 One independently timed interval contributing to a shared Clock. More...

Public Member Functions

 Clock () noexcept
 Construct zeroed shared clock state.
 Clock (const Clock &)=delete
 Copy constructor is deleted.
 Clock (Clock &&) noexcept
 Move constructor is defaulted.
Clock & operator= (const Clock &)=delete
 Copy assignment is deleted.
Clock & operator= (Clock &&) noexcept
 Move assignment is defaulted.
 ~Clock () noexcept
 Destructor.
Sample Measure ()
 Start an independent interval sample.
STORMBYTE_FORCE_INLINE Values GetValues () const noexcept
 Read Count, Time and MeanDuration under one lock.
std::uint64_t Count () const noexcept
 Number of completed samples.
STORMBYTE_FORCE_INLINE std::chrono::microseconds Time () const noexcept
 Cumulative duration of completed samples.
STORMBYTE_FORCE_INLINE std::chrono::microseconds MeanDuration () const noexcept
 Mean duration across completed samples.

Detailed Description

Thread-safe aggregate of independently timed operation samples.

Not a telemetry type and not inherited by leaves. Concurrent samples may share this Clock; each sample owns its own start time and completion is accumulated under the shared state lock. A Sample token itself has one owner and must not be accessed concurrently.

Constructor & Destructor Documentation

◆ Clock() [1/3]

StormByte::Clock::Clock ( )
noexcept

Construct zeroed shared clock state.

◆ Clock() [2/3]

StormByte::Clock::Clock ( const Clock & )
delete

Copy constructor is deleted.

◆ Clock() [3/3]

StormByte::Clock::Clock ( Clock && )
noexcept

Move constructor is defaulted.

◆ ~Clock()

StormByte::Clock::~Clock ( )
noexcept

Destructor.

Member Function Documentation

◆ Count()

std::uint64_t StormByte::Clock::Count ( ) const
noexcept

Number of completed samples.

Returns
Completed operation count.

◆ GetValues()

STORMBYTE_FORCE_INLINE Values StormByte::Clock::GetValues ( ) const
inlinenoexcept

Read Count, Time and MeanDuration under one lock.

Returns
Coherent completed-sample snapshot. The durations are built in the caller.

◆ MeanDuration()

STORMBYTE_FORCE_INLINE std::chrono::microseconds StormByte::Clock::MeanDuration ( ) const
inlinenoexcept

Mean duration across completed samples.

Returns
Average microseconds per operation, or 0 when Count() == 0. Built in the caller.

◆ Measure()

Sample StormByte::Clock::Measure ( )

Start an independent interval sample.

Returns
Move-only token; Stop it explicitly or let its destructor record it.

◆ operator=() [1/2]

Clock & StormByte::Clock::operator= ( Clock && )
noexcept

Move assignment is defaulted.

Returns
Reference to this clock.

◆ operator=() [2/2]

Clock & StormByte::Clock::operator= ( const Clock & )
delete

Copy assignment is deleted.

Returns
Reference to this clock.

◆ Time()

STORMBYTE_FORCE_INLINE std::chrono::microseconds StormByte::Clock::Time ( ) const
inlinenoexcept

Cumulative duration of completed samples.

Returns
Elapsed microseconds. Built in the caller.

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