-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add samples to check service/topic registration
- Loading branch information
1 parent
60c9f74
commit d00bb41
Showing
16 changed files
with
804 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
samples/cpp/monitoring/monitoring_get_services/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 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(monitoring_get_services) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(monitoring_get_services_src | ||
src/monitoring_get_services.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${monitoring_get_services_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/monitoring) |
76 changes: 76 additions & 0 deletions
76
samples/cpp/monitoring/monitoring_get_services/src/monitoring_get_services.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 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 <chrono> | ||
#include <iostream> | ||
#include <string> | ||
#include <map> | ||
#include <vector> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int run(0), runs(1000); | ||
std::chrono::steady_clock::time_point start_time; | ||
|
||
// initialize eCAL core API | ||
eCAL::Initialize(argc, argv, "monitoring get services"); | ||
|
||
// monitor for ever | ||
while(eCAL::Ok()) | ||
{ | ||
// GetServices | ||
{ | ||
std::map<std::tuple<std::string, std::string>, eCAL::SServiceMethodInformation> service_info_map; | ||
|
||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
eCAL::Util::GetServices(service_info_map); | ||
} | ||
|
||
auto num_services = service_info_map.size(); | ||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "GetServices : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_services << " services)" << std::endl; | ||
std::cout << std::endl; | ||
} | ||
|
||
// GetServiceNames | ||
{ | ||
std::vector<std::tuple<std::string, std::string>> service_method_names; | ||
|
||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
eCAL::Util::GetServiceNames(service_method_names); | ||
} | ||
|
||
auto num_services = service_method_names.size(); | ||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "GetServicesNames : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_services << " services)" << std::endl; | ||
std::cout << std::endl; | ||
} | ||
} | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
39 changes: 39 additions & 0 deletions
39
samples/cpp/monitoring/monitoring_get_topics/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 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(monitoring_get_topics) | ||
|
||
find_package(eCAL REQUIRED) | ||
|
||
set(monitoring_get_topics_src | ||
src/monitoring_get_topics.cpp | ||
) | ||
|
||
ecal_add_sample(${PROJECT_NAME} ${monitoring_get_topics_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/monitoring) |
75 changes: 75 additions & 0 deletions
75
samples/cpp/monitoring/monitoring_get_topics/src/monitoring_get_topics.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 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 <chrono> | ||
#include <iostream> | ||
#include <string> | ||
#include <unordered_map> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
int run(0), runs(1000); | ||
std::chrono::steady_clock::time_point start_time; | ||
|
||
// initialize eCAL core API | ||
eCAL::Initialize(argc, argv, "monitoring get topics"); | ||
|
||
// monitor for ever | ||
while(eCAL::Ok()) | ||
{ | ||
// GetTopics | ||
{ | ||
std::unordered_map<std::string, eCAL::SDataTypeInformation> topic_info_map; | ||
|
||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
eCAL::Util::GetTopics(topic_info_map); | ||
} | ||
|
||
auto num_topics = topic_info_map.size(); | ||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "GetTopics : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; | ||
std::cout << std::endl; | ||
} | ||
|
||
// GetTopicNames | ||
{ | ||
std::vector<std::string> topic_names; | ||
|
||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
eCAL::Util::GetTopicNames(topic_names); | ||
} | ||
|
||
auto num_topics = topic_names.size(); | ||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "GetTopicsNames : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; | ||
std::cout << std::endl; | ||
} | ||
} | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
52 changes: 52 additions & 0 deletions
52
samples/cpp/monitoring/monitoring_performance/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2019 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(monitoring_performance) | ||
|
||
find_package(eCAL REQUIRED) | ||
find_package(Protobuf REQUIRED) | ||
|
||
set(monitoring_performance_src | ||
src/monitoring_performance.cpp | ||
) | ||
|
||
set(monitoring_rec_proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/host.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/layer.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/monitoring.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/process.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/service.proto | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf/topic.proto | ||
) | ||
ecal_add_sample(${PROJECT_NAME} ${monitoring_performance_src}) | ||
PROTOBUF_TARGET_CPP(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/protobuf ${monitoring_rec_proto}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
eCAL::core | ||
protobuf::libprotobuf | ||
) | ||
|
||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) | ||
|
||
ecal_install_sample(${PROJECT_NAME}) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER samples/cpp/monitoring) |
91 changes: 91 additions & 0 deletions
91
samples/cpp/monitoring/monitoring_performance/src/monitoring_performance.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2019 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 <chrono> | ||
#include <iostream> | ||
#include <string> | ||
|
||
#ifdef _MSC_VER | ||
#pragma warning(push, 0) | ||
#endif | ||
#include <monitoring.pb.h> | ||
#ifdef _MSC_VER | ||
#pragma warning(pop) | ||
#endif | ||
|
||
#define MEASURE_VARIANT_STRING 1 | ||
#define MEASURE_VARIANT_STRUCT 1 | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
// initialize eCAL core API | ||
eCAL::Initialize(argc, argv, "monitoring performance", eCAL::Init::All); | ||
|
||
int runs(100); | ||
int run(0); | ||
std::chrono::steady_clock::time_point start_time; | ||
|
||
// monitor for ever | ||
while(eCAL::Ok()) | ||
{ | ||
#if MEASURE_VARIANT_STRING | ||
// take snapshots as string (and parse it afterwards to protobuf) | ||
{ | ||
int num_topics(0); | ||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
std::string monitoring_s; | ||
eCAL::pb::Monitoring monitoring; | ||
eCAL::Monitoring::GetMonitoring(monitoring_s); | ||
monitoring.ParseFromString(monitoring_s); | ||
num_topics = monitoring.topics_size(); | ||
} | ||
|
||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "Monitoring time to string : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; | ||
} | ||
#endif // MEASURE_VARIANT_STRING | ||
|
||
#if MEASURE_VARIANT_STRUCT | ||
// take snapshots as monitoring struct | ||
{ | ||
size_t num_topics(0); | ||
start_time = std::chrono::steady_clock::now(); | ||
for (run = 0; run < runs; ++run) | ||
{ | ||
eCAL::Monitoring::SMonitoring monitoring; | ||
eCAL::Monitoring::GetMonitoring(monitoring); | ||
num_topics = monitoring.publisher.size() + monitoring.subscriber.size(); | ||
} | ||
auto diff_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start_time); | ||
std::cout << "Monitoring time to structs : " << static_cast<double>(diff_time.count()) / runs << " ms" << " (" << num_topics << " topics)" << std::endl; | ||
} | ||
#endif // MEASURE_VARIANT_STRUCT | ||
|
||
std::cout << std::endl; | ||
} | ||
|
||
// finalize eCAL API | ||
eCAL::Finalize(); | ||
|
||
return(0); | ||
} |
Oops, something went wrong.