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

Stopwatch for measuring execution time of operations. More...

#include <StormByte/telemetry.hxx>

Public Member Functions

 Clock () noexcept
 Construct zeroed clock counters.
 
 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.
 
void Start () noexcept
 Start measuring an interval.
 
void Stop () noexcept
 Stop measuring and accumulate elapsed time.
 
std::uint64_t Count () const noexcept
 Number of completed Start/Stop intervals.
 
std::chrono::microseconds Time () const noexcept
 Cumulative duration of completed intervals.
 
std::chrono::microseconds MeanDuration () const noexcept
 Mean duration across completed intervals.
 

Detailed Description

Stopwatch for measuring execution time of operations.

Not a telemetry type and not inherited by leaves.

Note
Not safe for concurrent Start/Stop on the same instance; Telemetry::Clock(name) is safe to call concurrently (distinct or same key) for map access only.

Constructor & Destructor Documentation

◆ Clock() [1/3]

StormByte::Clock::Clock ( )
noexcept

Construct zeroed clock counters.

◆ 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 Start/Stop intervals.

Returns
Completed operation count.

◆ MeanDuration()

std::chrono::microseconds StormByte::Clock::MeanDuration ( ) const
noexcept

Mean duration across completed intervals.

Returns
Average microseconds per operation, or 0 when Count() == 0.

◆ 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.

◆ Start()

void StormByte::Clock::Start ( )
noexcept

Start measuring an interval.

Stores t0 = steady_clock::now(). A second Start() without Stop() replaces t0 (no nesting).

◆ Stop()

void StormByte::Clock::Stop ( )
noexcept

Stop measuring and accumulate elapsed time.

When active, adds elapsed duration to Time, increments Count by 1, and clears t0. If no interval was started, this is a no-op.

◆ Time()

std::chrono::microseconds StormByte::Clock::Time ( ) const
noexcept

Cumulative duration of completed intervals.

Returns
Elapsed microseconds.

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