| 14 | class PerfModule final : public SimModule { |
| 15 | public: |
| 16 | void Init(InitHelper& h) override { |
| 17 | std::string v = h.GetParameter("sub_topics"); |
| 18 | if (!v.empty()) { |
| 19 | boost::split(subs_, v, boost::is_any_of(",")); |
| 20 | for (const std::string& s : subs_) h.Subscribe(s); |
| 21 | } |
| 22 | v = h.GetParameter("pub_topics"); |
| 23 | if (!v.empty()) { |
| 24 | boost::split(pubs_, v, boost::is_any_of(",")); |
| 25 | for (const std::string& p : pubs_) h.Publish(p); |
| 26 | } |
| 27 | if (subs_.empty() && pubs_.empty()) throw std::invalid_argument("at least one sub_topics/pub_topics provided."); |
| 28 | |
| 29 | msg_size_ = std::stoi(h.GetParameter("msg_size")); |
| 30 | pub_payload_.assign(msg_size_, 's'); |
| 31 | } |
| 32 | |
| 33 | void Reset(ResetHelper& h) override { |
| 34 | last_step_time_ = total_step_calling_period_ = max_step_calling_period_ = total_step_execution_time_ = |