10#include "wfree_unordered_map.hpp"
11#include "architecture.hpp"
12#include "fixed_string.hpp"
13#include "statistics.hpp"
21constexpr int MAX_NR_COUNTERS = 1024;
25 int64_t previous_value;
34template<basic_fixed_
string Tag>
39 tt_no_inline
void add_to_map()
const noexcept
45 int64_t increment()
const noexcept
47 ttlet value = counter.
fetch_add(1, std::memory_order::relaxed);
50 [[unlikely]] add_to_map();
56 [[nodiscard]] int64_t read()
const noexcept
58 return counter.
load(std::memory_order::relaxed);
64template<basic_fixed_
string Tag>
65inline int64_t increment_counter() noexcept
70template<basic_fixed_
string Tag>
71[[nodiscard]]
inline int64_t read_counter() noexcept
73 return counter_functor<Tag>{}.read();
81 auto &item = counter_map[tag];
83 ttlet *
const count_ptr = item.counter;
84 ttlet
count = count_ptr !=
nullptr ? item.counter->load(std::memory_order::relaxed) : 0;
85 ttlet count_since_last_read =
count - item.previous_value;
86 item.previous_value =
count;
87 return {
count, count_since_last_read};
Definition counters.hpp:23
Definition counters.hpp:35
Definition wfree_unordered_map.hpp:56