-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] shm-monitoring-performance #1645
Changes from 2 commits
dd66730
51657a4
70b93ba
2100496
ba295e3
8e8d9ee
0b9cbe1
7618288
6753be5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,9 @@ namespace eCAL | |
{ | ||
if(m_created) return; | ||
|
||
// send registration to shared memory and to udp | ||
m_use_registration_udp = !Config::Experimental::IsNetworkMonitoringDisabled(); | ||
m_use_registration_shm = Config::Experimental::IsShmMonitoringEnabled(); | ||
// send registration over udp or shared memory | ||
m_use_registration_udp = Config::IsNetworkEnabled; | ||
m_use_registration_shm = !m_use_registration_udp; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused. shouldn't the registration provider / receiver also be passed configuration objects (maybe just registration configuration) in their constructors? But maybe that's for a different PR. |
||
if (m_use_registration_udp) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,9 +69,9 @@ namespace eCAL | |||||
{ | ||||||
if(m_created) return; | ||||||
|
||||||
// receive registration from shared memory and or udp | ||||||
m_use_registration_udp = !Config::Experimental::IsNetworkMonitoringDisabled(); | ||||||
m_use_registration_shm = Config::Experimental::IsShmMonitoringEnabled(); | ||||||
// receive registration via udp or shared memory | ||||||
m_use_registration_udp = Config::IsNetworkEnabled; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: implicit conversion 'bool (*)()' -> bool [readability-implicit-bool-conversion]
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rex-schilasky 🤣 this is really bad, did this not generate a regular warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :-( |
||||||
m_use_registration_shm = !m_use_registration_udp; | ||||||
|
||||||
if (m_use_registration_udp) | ||||||
{ | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON) | ||
|
||
project(massive_pub_sub) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(massive_pub_sub_src | ||
src/massive_pub_sub.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${massive_pub_sub_src}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
eCAL::core | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/benchmarks/massive_pub_sub) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
#include <ecal/ecal.h> | ||
|
||
#include <iostream> | ||
#include <chrono> | ||
#include <sstream> | ||
#include <thread> | ||
#include <vector> | ||
|
||
const int subscriber_number (5000); | ||
|
||
const int publisher_number (5000); | ||
const int publisher_type_encoding_size_bytes (10*1024); | ||
const int publisher_type_descriptor_size_bytes (10*1024); | ||
|
||
const int in_between_sleep_sec (5); | ||
const int final_sleep_sec (120); | ||
|
||
std::string GenerateSizedString(const std::string& name, size_t totalSize) | ||
{ | ||
if (name.empty() || totalSize == 0) { | ||
return ""; | ||
} | ||
|
||
std::string result; | ||
result.reserve(totalSize); | ||
|
||
while (result.size() + name.size() <= totalSize) { | ||
result += name; | ||
} | ||
|
||
if (result.size() < totalSize) { | ||
result += name.substr(0, totalSize - result.size()); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
// initialize eCAL API | ||
eCAL::Initialize(argc, argv, "massive_pub_sub"); | ||
|
||
eCAL::Util::EnableLoopback(true); | ||
|
||
// create subscriber | ||
std::vector<eCAL::CSubscriber> vector_of_subscriber; | ||
std::cout << "Subscriber creation started. (" << subscriber_number << ")" << std::endl; | ||
{ | ||
// start time measurement | ||
auto start_time = std::chrono::high_resolution_clock::now(); | ||
|
||
for (int i = 0; i < subscriber_number; i++) | ||
{ | ||
// publisher topic name | ||
std::stringstream tname; | ||
tname << "TOPIC_" << i; | ||
|
||
// create subscriber | ||
vector_of_subscriber.emplace_back(tname.str()); | ||
} | ||
// stop time measurement | ||
auto end_time = std::chrono::high_resolution_clock::now(); | ||
|
||
// calculate the duration | ||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count(); | ||
std::cout << "Time taken for subscriber creation: " << duration << " milliseconds" << std::endl; | ||
} | ||
|
||
// sleep for a few seconds | ||
std::this_thread::sleep_for(std::chrono::seconds(in_between_sleep_sec)); | ||
|
||
// create publisher | ||
std::vector<eCAL::CPublisher> vector_of_publisher; | ||
std::cout << "Publisher creation started. (" << publisher_number << ")" << std::endl; | ||
{ | ||
// start time measurement | ||
auto start_time = std::chrono::high_resolution_clock::now(); | ||
|
||
eCAL::SDataTypeInformation data_type_info; | ||
data_type_info.name = "TOPIC_TYPE_NAME"; | ||
data_type_info.encoding = GenerateSizedString("TOPIC_TYPE_ENCODING", publisher_type_encoding_size_bytes); | ||
data_type_info.descriptor = GenerateSizedString("TOPIC_TYPE_DESCRIPTOR", publisher_type_descriptor_size_bytes); | ||
|
||
for (int i = 0; i < publisher_number; i++) | ||
{ | ||
// publisher topic name | ||
std::stringstream tname; | ||
tname << "TOPIC_" << i; | ||
|
||
// create publisher | ||
vector_of_publisher.emplace_back(tname.str(), data_type_info); | ||
} | ||
// stop time measurement | ||
auto end_time = std::chrono::high_resolution_clock::now(); | ||
|
||
// calculate the duration | ||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count(); | ||
std::cout << "Time taken for publisher creation: " << duration << " milliseconds" << std::endl; | ||
} | ||
std::cout << std::endl; | ||
|
||
// sleep for a few seconds | ||
std::this_thread::sleep_for(std::chrono::seconds(final_sleep_sec)); | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: implicit conversion 'bool (*)()' -> bool [readability-implicit-bool-conversion]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Config::IsNetworkEnabled()
😨