Public Member Functions | Static Public Member Functions | List of all members
rapidsmpf::Statistics::Stat Class Reference

Represents a single tracked statistic. More...

#include <statistics.hpp>

Public Member Functions

 Stat ()=default
 Default-constructs a Stat.
 
 Stat (std::size_t count, double value, double max)
 Constructs a Stat with explicit field values. More...
 
auto operator<=> (Stat const &) const noexcept=default
 Three-way comparison operator. More...
 
void add (double value)
 Adds a value to this statistic. More...
 
std::size_t count () const noexcept
 Returns the number of updates applied to this statistic. More...
 
double value () const noexcept
 Returns the total accumulated value. More...
 
double max () const noexcept
 Returns the maximum value seen across all add() calls. More...
 
std::uint8_t * serialize (std::uint8_t *out) const
 Serializes this Stat to a byte buffer. More...
 
Stat merge (Stat const &other) const
 Merges another Stat into this one, returning the combined result. More...
 

Static Public Member Functions

static constexpr std::size_t serialized_size () noexcept
 Returns the serialized size of this Stat in bytes. More...
 
static std::pair< Stat, std::span< std::uint8_t const > > deserialize (std::span< std::uint8_t const > data)
 Deserializes a Stat from a byte buffer. More...
 

Detailed Description

Represents a single tracked statistic.

Note
Stat is not thread-safe. Thread safety is provided by the enclosing Statistics object's mutex.

Definition at line 292 of file statistics.hpp.

Constructor & Destructor Documentation

◆ Stat()

rapidsmpf::Statistics::Stat::Stat ( std::size_t  count,
double  value,
double  max 
)

Constructs a Stat with explicit field values.

Parameters
countNumber of updates.
valueTotal accumulated value.
maxMaximum value seen.

Member Function Documentation

◆ add()

void rapidsmpf::Statistics::Stat::add ( double  value)

Adds a value to this statistic.

Parameters
valueThe value to add.

◆ count()

std::size_t rapidsmpf::Statistics::Stat::count ( ) const
noexcept

Returns the number of updates applied to this statistic.

Returns
The number of times add() was called.

◆ deserialize()

static std::pair<Stat, std::span<std::uint8_t const> > rapidsmpf::Statistics::Stat::deserialize ( std::span< std::uint8_t const >  data)
static

Deserializes a Stat from a byte buffer.

Parameters
dataThe input buffer. Must contain at least serialized_size() bytes.
Returns
A pair of the deserialized Stat and the remaining unconsumed bytes.
Exceptions
std::invalid_argumentIf the data is truncated.

◆ max()

double rapidsmpf::Statistics::Stat::max ( ) const
noexcept

Returns the maximum value seen across all add() calls.

Returns
The maximum value added, or negative infinity if add() was never called.

◆ merge()

Stat rapidsmpf::Statistics::Stat::merge ( Stat const &  other) const

Merges another Stat into this one, returning the combined result.

Counts and values are summed; the maximum is taken.

Parameters
otherThe Stat to merge with.
Returns
A new Stat containing the merged result.

◆ operator<=>()

auto rapidsmpf::Statistics::Stat::operator<=> ( Stat const &  ) const
defaultnoexcept

Three-way comparison operator.

Performs memberwise comparison of all data members.

Returns
The ordering result of the memberwise comparison.

◆ serialize()

std::uint8_t* rapidsmpf::Statistics::Stat::serialize ( std::uint8_t *  out) const

Serializes this Stat to a byte buffer.

Parameters
outPointer to the output buffer. Must have at least serialized_size() bytes available.
Returns
Pointer past the last byte written.

◆ serialized_size()

static constexpr std::size_t rapidsmpf::Statistics::Stat::serialized_size ( )
inlinestaticconstexprnoexcept

Returns the serialized size of this Stat in bytes.

We size each field individually rather than using sizeof(Stat) to avoid platform-dependent struct padding.

Returns
The number of bytes needed to serialize this Stat.

Definition at line 354 of file statistics.hpp.

◆ value()

double rapidsmpf::Statistics::Stat::value ( ) const
noexcept

Returns the total accumulated value.

Returns
The sum of all values added.

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