Skip to main content

chronon::observe::FixedCounterStorage

Sparse array of SimpleCounters for per-unit storage. More...

#include <Counter.hpp>

Public Functions

Name
size_tsize() const
voidrollbackAllEpochs()
voidresetAll()
const std::string &name() const
const CounterInfo &info(CounterId id) const
SimpleCounter &getUnchecked(CounterId id)
Hot-path access by counter id (~1-2ns).
const SimpleCounter &getUnchecked(CounterId id) const
SimpleCounter &get(CounterId id)
Bounds-checked access; grows storage if needed.
const SimpleCounter &get(CounterId id) const
template <typename Fn >
void
forEach(Fn && fn) const
voidensureCapacity(size_t n)
std::vector< SimpleCounter > &counters()
const std::vector< SimpleCounter > &counters() const
voidcommitAllEpochs()
CounterIdaddCounter(const std::string & name, const std::string & description ="", const std::string & unit ="")
Register a counter dynamically.
FixedCounterStorage(std::string name)

Detailed Description

class chronon::observe::FixedCounterStorage;

Sparse array of SimpleCounters for per-unit storage.

O(1) unchecked access via getUnchecked(). Memory cost is num_counters × 16 bytes.

Public Functions Documentation

function size

inline size_t size() const

function rollbackAllEpochs

inline void rollbackAllEpochs()

function resetAll

inline void resetAll()

function name

inline const std::string & name() const

function info

inline const CounterInfo & info(
CounterId id
) const

function getUnchecked

inline SimpleCounter & getUnchecked(
CounterId id
)

Hot-path access by counter id (~1-2ns).

PRECONDITION: Counter must have been added via addCounter(); no bounds checking.

function getUnchecked

inline const SimpleCounter & getUnchecked(
CounterId id
) const

function get

inline SimpleCounter & get(
CounterId id
)

Bounds-checked access; grows storage if needed.

function get

inline const SimpleCounter & get(
CounterId id
) const

function forEach

template <typename Fn >
inline void forEach(
Fn && fn
) const

function ensureCapacity

inline void ensureCapacity(
size_t n
)

function counters

inline std::vector< SimpleCounter > & counters()

function counters

inline const std::vector< SimpleCounter > & counters() const

function commitAllEpochs

inline void commitAllEpochs()

function addCounter

inline CounterId addCounter(
const std::string & name,
const std::string & description ="",
const std::string & unit =""
)

Register a counter dynamically.

Return: Counter ID assigned to this counter.

function FixedCounterStorage

inline explicit FixedCounterStorage(
std::string name
)

Updated on 2026-05-26 at 05:42:33 +0000