diff --git a/include/reactor-cpp/statistics.hh b/include/reactor-cpp/statistics.hh index ce03e91b..633a4249 100644 --- a/include/reactor-cpp/statistics.hh +++ b/include/reactor-cpp/statistics.hh @@ -40,6 +40,10 @@ private: inline static std::atomic_size_t processed_reactions_{0}; // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) inline static std::atomic_size_t triggered_actions_{0}; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) + inline static std::atomic_size_t set_ports_{0}; + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) + inline static std::atomic_size_t scheduled_actions_{0}; inline static void increment(std::atomic_size_t& counter) { if constexpr (enabled_) { @@ -56,6 +60,8 @@ public: inline static void increment_processed_events() { increment(processed_events_); } inline static void increment_processed_reactions() { increment(processed_reactions_); } inline static void increment_triggered_actions() { increment(triggered_actions_); } + inline static void increment_set_ports() { increment(set_ports_); } + inline static void increment_scheduled_actions() { increment(scheduled_actions_); } inline static auto reactor_instances() { return reactor_instances_.load(std::memory_order_acquire); } inline static auto connections() { return connections_.load(std::memory_order_acquire); } @@ -65,6 +71,8 @@ public: inline static auto processed_events() { return processed_events_.load(std::memory_order_acquire); } inline static auto processed_reactions() { return processed_reactions_.load(std::memory_order_acquire); } inline static auto triggered_actions() { return triggered_actions_.load(std::memory_order_acquire); } + inline static auto set_ports() { return set_ports_.load(std::memory_order_acquire); } + inline static auto scheduled_actions() { return scheduled_actions_.load(std::memory_order_acquire); } inline static void print() { if constexpr (enabled_) { @@ -79,6 +87,8 @@ public: reactor::log::Info() << " - processed events: " << processed_events(); reactor::log::Info() << " - triggered actions: " << triggered_actions(); reactor::log::Info() << " - processed reactions: " << processed_reactions(); + reactor::log::Info() << " - set ports set: " << set_ports(); + reactor::log::Info() << " - scheduled actions: " << scheduled_actions(); reactor::log::Info() << "-----------------------------------------------------------"; } } diff --git a/lib/scheduler.cc b/lib/scheduler.cc index a33b4023..b06936d0 100644 --- a/lib/scheduler.cc +++ b/lib/scheduler.cc @@ -438,6 +438,7 @@ void Scheduler::schedule_sync(BaseAction* action, const Tag& tag) { << " with tag " << tag; reactor_assert(logical_time_ < tag); tracepoint(reactor_cpp, schedule_action, action->container()->fqn(), action->name(), tag); + Statistics::increment_scheduled_actions(); const auto& action_list = event_queue_.insert_event_at(tag); action_list->push_back(action); @@ -484,6 +485,7 @@ auto Scheduler::schedule_empty_async_at(const Tag& tag) -> bool { void Scheduler::set_port(BasePort* port) { log_.debug() << "Set port " << port->fqn(); + Statistics::increment_set_ports(); // We do not check here if port is already in the list. This means clean() // could be called multiple times for a single port. However, calling