Skip to content

Commit 6dc85b4

Browse files
committed
also collect number of set ports and scheduled actions
1 parent cf6c1cd commit 6dc85b4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/reactor-cpp/statistics.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ private:
4040
inline static std::atomic_size_t processed_reactions_{0};
4141
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
4242
inline static std::atomic_size_t triggered_actions_{0};
43+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
44+
inline static std::atomic_size_t set_ports_{0};
45+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
46+
inline static std::atomic_size_t scheduled_actions_{0};
4347

4448
inline static void increment(std::atomic_size_t& counter) {
4549
if constexpr (enabled_) {
@@ -56,6 +60,8 @@ public:
5660
inline static void increment_processed_events() { increment(processed_events_); }
5761
inline static void increment_processed_reactions() { increment(processed_reactions_); }
5862
inline static void increment_triggered_actions() { increment(triggered_actions_); }
63+
inline static void increment_set_ports() { increment(set_ports_); }
64+
inline static void increment_scheduled_actions() { increment(scheduled_actions_); }
5965

6066
inline static auto reactor_instances() { return reactor_instances_.load(std::memory_order_acquire); }
6167
inline static auto connections() { return connections_.load(std::memory_order_acquire); }
@@ -65,6 +71,8 @@ public:
6571
inline static auto processed_events() { return processed_events_.load(std::memory_order_acquire); }
6672
inline static auto processed_reactions() { return processed_reactions_.load(std::memory_order_acquire); }
6773
inline static auto triggered_actions() { return triggered_actions_.load(std::memory_order_acquire); }
74+
inline static auto set_ports() { return set_ports_.load(std::memory_order_acquire); }
75+
inline static auto scheduled_actions() { return scheduled_actions_.load(std::memory_order_acquire); }
6876

6977
inline static void print() {
7078
if constexpr (enabled_) {
@@ -79,6 +87,8 @@ public:
7987
reactor::log::Info() << " - processed events: " << processed_events();
8088
reactor::log::Info() << " - triggered actions: " << triggered_actions();
8189
reactor::log::Info() << " - processed reactions: " << processed_reactions();
90+
reactor::log::Info() << " - set ports set: " << set_ports();
91+
reactor::log::Info() << " - scheduled actions: " << scheduled_actions();
8292
reactor::log::Info() << "-----------------------------------------------------------";
8393
}
8494
}

lib/scheduler.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ void Scheduler::schedule_sync(BaseAction* action, const Tag& tag) {
438438
<< " with tag " << tag;
439439
reactor_assert(logical_time_ < tag);
440440
tracepoint(reactor_cpp, schedule_action, action->container()->fqn(), action->name(), tag);
441+
Statistics::increment_scheduled_actions();
441442

442443
const auto& action_list = event_queue_.insert_event_at(tag);
443444
action_list->push_back(action);
@@ -484,6 +485,7 @@ auto Scheduler::schedule_empty_async_at(const Tag& tag) -> bool {
484485

485486
void Scheduler::set_port(BasePort* port) {
486487
log_.debug() << "Set port " << port->fqn();
488+
Statistics::increment_set_ports();
487489

488490
// We do not check here if port is already in the list. This means clean()
489491
// could be called multiple times for a single port. However, calling

0 commit comments

Comments
 (0)