chronon::observe::Counter
#include <LocalCounter.hpp>
Public Functions
| Name | |
|---|---|
| ~Counter() =default | |
| const std::string & | unit() const |
| void | reset() |
| Counter & | operator=(const Counter & ) =delete |
| Counter & | operator=(Counter && other) |
| Counter & | operator+=(uint64_t delta) |
| Counter & | operator++() |
| const std::string & | name() const |
| bool | isRegistered() const |
| CounterId | id() const |
| uint64_t | get() const |
| const std::string & | description() const |
| Counter(ObservableUnit * owner, std::string_view name, std::string_view description ="", std::string_view unit ="") | |
| Counter(counter_detail::InternalConstructionTag , ObservableUnit * owner, std::string_view name, std::string_view description ="", std::string_view unit ="") | |
| Counter(const Counter & ) =delete | |
| Counter(Counter && other) |
Friends
| Name | |
|---|---|
| class | ObservableUnit |
Detailed Description
class chronon::observe::Counter;
Counter - Per-instance counter declared as a unit member.
Each unit instance has its own counter with separate values:
- Counter names include the unit's hierarchical path (e.g., "cpu0.alu0.ops")
- Fast increment path (~2-3ns) via direct context access
Usage:
class ALU : public TickableUnit, public ObservableUnit {
Counter ops_{this, "ops", "Operations executed"};
Counter stalls_{this, "stalls", "Stall cycles"};
void tick() override {
++ops_; // Fast: ~2-3ns
stalls_ += 5; // Add 5
}
};
Output (CSV):
cycle,unit_name,counter_name,value
10000,cpu0.alu0,ops,2500
10000,cpu0.alu1,ops,2400
10000,cpu1.alu0,ops,2550
Public Functions Documentation
function ~Counter
~Counter() =default
function unit
inline const std::string & unit() const
function reset
inline void reset()
function operator=
Counter & operator=(
const Counter &
) =delete
function operator=
Counter & operator=(
Counter && other
)
function operator+=
inline Counter & operator+=(
uint64_t delta
)
function operator++
inline Counter & operator++()
function name
inline const std::string & name() const
function isRegistered
inline bool isRegistered() const
function id
inline CounterId id() const
function get
inline uint64_t get() const
function description
inline const std::string & description() const
function Counter
Counter(
ObservableUnit * owner,
std::string_view name,
std::string_view description ="",
std::string_view unit =""
)
Parameters:
- owner The ObservableUnit that owns this counter
- name Counter name (will be prefixed with unit path)
- description Counter description
- unit Unit of measurement (e.g., "ops", "cycles", "bytes")
Construct a counter.
function Counter
Counter(
counter_detail::InternalConstructionTag ,
ObservableUnit * owner,
std::string_view name,
std::string_view description ="",
std::string_view unit =""
)
function Counter
Counter(
const Counter &
) =delete
function Counter
Counter(
Counter && other
)
Friends
friend ObservableUnit
friend class ObservableUnit(
ObservableUnit
);
Updated on 2026-07-06 at 09:03:34 +0000