Skip to content

Commit

Permalink
also collect number of set ports and scheduled actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed May 17, 2023
1 parent f29fb4b commit 92b7485
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/reactor-cpp/statistics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -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); }
Expand All @@ -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_) {
Expand All @@ -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() << "-----------------------------------------------------------";
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 92b7485

Please # to comment.