Skip to content

Commit 678fd19

Browse files
Benchmark example updated (#5460) (#5500)
* Benchmark example updated (#5460) * Refs #22321: Benchmark example updated Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Test CI for benchmark example and issue fixing Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Fix type variable error Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Corrections after review Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Uncrustify fix Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Uncrustified 2 Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Delate unused variable <sent> from PublisherApp.hpp Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Extra corrections and fixes Signed-off-by: Javier Gil Aviles <[email protected]> * Refs #22321: Compose simplify for test Signed-off-by: Javier Gil Aviles <[email protected]> --------- Signed-off-by: Javier Gil Aviles <[email protected]> (cherry picked from commit e99d6f3) # Conflicts: # versions.md * Fix conflict of versions.md Signed-off-by: Javier Gil Aviles <[email protected]> --------- Signed-off-by: Javier Gil Aviles <[email protected]> Co-authored-by: Javier Gil Avilés <[email protected]> Co-authored-by: Javier Gil Aviles <[email protected]>
1 parent a2d8e8b commit 678fd19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6231
-0
lines changed

examples/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
set(fastdds_FOUND TRUE)
1616

17+
add_subdirectory(cpp/benchmark)
1718
add_subdirectory(cpp/configuration)
1819
add_subdirectory(cpp/content_filter)
1920
add_subdirectory(cpp/custom_payload_pool)
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file Application.cpp
17+
*
18+
*/
19+
20+
#include "Application.hpp"
21+
22+
#include "SubscriberApp.hpp"
23+
#include "PublisherApp.hpp"
24+
25+
using namespace eprosima::fastdds::dds;
26+
27+
namespace eprosima {
28+
namespace fastdds {
29+
namespace examples {
30+
namespace benchmark {
31+
32+
//! Factory method to create a publisher or subscriber
33+
std::shared_ptr<Application> Application::make_app(
34+
const CLIParser::benchmark_config& config)
35+
{
36+
std::shared_ptr<Application> entity;
37+
switch (config.entity)
38+
{
39+
case CLIParser::EntityKind::PUBLISHER:
40+
entity = std::make_shared<PublisherApp>(config.pub_config);
41+
break;
42+
case CLIParser::EntityKind::SUBSCRIBER:
43+
entity = std::make_shared<SubscriberApp>(config.sub_config);
44+
break;
45+
case CLIParser::EntityKind::UNDEFINED:
46+
default:
47+
throw std::runtime_error("Entity initialization failed");
48+
break;
49+
}
50+
return entity;
51+
}
52+
53+
} // namespace benchmark
54+
} // namespace examples
55+
} // namespace fastdds
56+
} // namespace eprosima
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file Application.hpp
17+
*
18+
*/
19+
20+
#ifndef FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP
21+
#define FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP
22+
23+
#include <atomic>
24+
25+
#include "CLIParser.hpp"
26+
27+
namespace eprosima {
28+
namespace fastdds {
29+
namespace examples {
30+
namespace benchmark {
31+
32+
class Application
33+
{
34+
public:
35+
36+
//! Virtual destructor
37+
virtual ~Application() = default;
38+
39+
//! Run application
40+
virtual void run() = 0;
41+
42+
//! Trigger the end of execution
43+
virtual void stop() = 0;
44+
45+
//! Factory method to create applications based on configuration
46+
static std::shared_ptr<Application> make_app(
47+
const CLIParser::benchmark_config& config);
48+
};
49+
50+
} // namespace benchmark
51+
} // namespace examples
52+
} // namespace fastdds
53+
} // namespace eprosima
54+
55+
#endif // FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP

0 commit comments

Comments
 (0)