Skip to content

Commit

Permalink
Benchmark example updated (#5460)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Javgilavi authored and mergify[bot] committed Dec 17, 2024
1 parent 56f9a3c commit 2bcbcc8
Show file tree
Hide file tree
Showing 47 changed files with 6,234 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

set(fastdds_FOUND TRUE)

add_subdirectory(cpp/benchmark)
add_subdirectory(cpp/configuration)
add_subdirectory(cpp/content_filter)
add_subdirectory(cpp/custom_payload_pool)
Expand Down
56 changes: 56 additions & 0 deletions examples/cpp/benchmark/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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.

/**
* @file Application.cpp
*
*/

#include "Application.hpp"

#include "SubscriberApp.hpp"
#include "PublisherApp.hpp"

using namespace eprosima::fastdds::dds;

namespace eprosima {
namespace fastdds {
namespace examples {
namespace benchmark {

//! Factory method to create a publisher or subscriber
std::shared_ptr<Application> Application::make_app(
const CLIParser::benchmark_config& config)
{
std::shared_ptr<Application> entity;
switch (config.entity)
{
case CLIParser::EntityKind::PUBLISHER:
entity = std::make_shared<PublisherApp>(config.pub_config);
break;
case CLIParser::EntityKind::SUBSCRIBER:
entity = std::make_shared<SubscriberApp>(config.sub_config);
break;
case CLIParser::EntityKind::UNDEFINED:
default:
throw std::runtime_error("Entity initialization failed");
break;
}
return entity;
}

} // namespace benchmark
} // namespace examples
} // namespace fastdds
} // namespace eprosima
55 changes: 55 additions & 0 deletions examples/cpp/benchmark/Application.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// 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.

/**
* @file Application.hpp
*
*/

#ifndef FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP
#define FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP

#include <atomic>

#include "CLIParser.hpp"

namespace eprosima {
namespace fastdds {
namespace examples {
namespace benchmark {

class Application
{
public:

//! Virtual destructor
virtual ~Application() = default;

//! Run application
virtual void run() = 0;

//! Trigger the end of execution
virtual void stop() = 0;

//! Factory method to create applications based on configuration
static std::shared_ptr<Application> make_app(
const CLIParser::benchmark_config& config);
};

} // namespace benchmark
} // namespace examples
} // namespace fastdds
} // namespace eprosima

#endif // FASTDDS_EXAMPLES_CPP_BENCHMARK__APPLICATION_HPP
Loading

0 comments on commit 2bcbcc8

Please sign in to comment.