Skip to content

Commit

Permalink
Added variable message length. Added script for reproduce tests made.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpauno committed Feb 22, 2019
1 parent b43332c commit 7842991
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rclcpp_performance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ament_export_dependencies(rosidl_default_runtime)
ament_package()

install(
PROGRAMS scripts/posprocess_logging
PROGRAMS scripts/posprocess_logging scripts/performance_test
DESTINATION lib/${PROJECT_NAME}
)

Expand Down
1 change: 1 addition & 0 deletions rclcpp_performance/msg/MatchingPublisher.msg
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
uint64 publisher_id
uint64 message_id
uint8[] data
154 changes: 154 additions & 0 deletions rclcpp_performance/scripts/performance_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#!/bin/bash

TEST_FOLDERS=(
"test_intra_shared_10ms_n100_m10000_l100000"
"test_inter_shared_10ms_n100_m10000_l100000"
"test_intra_unique_10ms_n100_m10000_l100000"
"test_inter_unique_10ms_n100_m10000_l100000"

"test_intra_shared_10ms_n10_m10000_l1000000"
"test_inter_shared_10ms_n10_m10000_l1000000"
"test_intra_unique_10ms_n10_m10000_l1000000"
"test_inter_unique_10ms_n10_m10000_l1000000"

"test_intra_shared_10ms_n1_m10000_l10000000"
"test_inter_shared_10ms_n1_m10000_l10000000"
"test_intra_unique_10ms_n1_m10000_l10000000"
"test_inter_unique_10ms_n1_m10000_l10000000"

# These tests below suffers of starvation
# "test_intra_shared_10ms_n5_m100_l10000000"
# "test_inter_shared_10ms_n5_m100_l10000000"
)

COMMAND_ARGUMENTS=(
"-p 10 -n 100 -m 10000 -l 100000 -intra"
"-p 10 -n 100 -m 10000 -l 100000"
"-p 10 -n 100 -m 10000 -l 100000 -intra -unique"
"-p 10 -n 100 -m 10000 -l 100000 -unique"

"-p 10 -n 10 -m 10000 -l 1000000 -intra"
"-p 10 -n 10 -m 10000 -l 1000000"
"-p 10 -n 10 -m 10000 -l 1000000 -intra -unique"
"-p 10 -n 10 -m 10000 -l 1000000 -unique"

"-p 10 -n 1 -m 10000 -l 10000000 -intra"
"-p 10 -n 1 -m 10000 -l 10000000"
"-p 10 -n 1 -m 10000 -l 10000000 -intra -unique"
"-p 10 -n 1 -m 10000 -l 10000000 -unique"

# "-p 10 -n 5 -m 10000 -l 10000000 -intra"
# "-p 10 -n 5 -m 10000 -l 10000000"
)


DESCRIPTION=(
"Intraprocess, shared publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
"Interprocess, shared publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
"Intraprocess, unique publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
"Interprocess, unique publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."

"Intraprocess, shared publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
"Interprocess, shared publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
"Intraprocess, unique publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
"Interprocess, unique publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."

"Intraprocess, shared publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
"Interprocess, shared publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
"Intraprocess, unique publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
"Interprocess, unique publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."

# "Intraprocess, shared publish, 5 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
# "Interprocess, shared publish, 5 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
)

main()
{
set -e
parse_arguments "$@"
if [[ $skip -eq 0 ]]; then
run_tests
fi
show_results
}

parse_arguments()
{
set -e
out_dir="logs"
skip=0

while [[ $# > 0 ]]
do
key="$1"
case $key in
-d|--dir)
out_dir="$2"
shift # past argument
;;
-s|--skip)
skip=1
;;
-h|--help)
print_help
;;
*)
print_help
;;
esac
shift # past argument or value
done
}

print_help()
{
echo "Usage: $0 -d OUTPUT_DIR [--skip]"
echo "The logs file will be generated inside OUTPUT_DIR"
echo "Options:"
echo -e "\t\t-s|--skip: Only posprocess and show results, skip running tests."
exit 0
}

run_tests()
{
set -e
mkdir -p $out_dir
pushd $out_dir > /dev/null

i=0
for folder in "${TEST_FOLDERS[@]}"
do
echo -e "\e[34mRunning performance test with the following configuration:\e[39m"
echo -e "\e[34m\t\t${COMMAND_ARGUMENTS[i]}\e[39m"
mkdir -p $folder
ros2 run rclcpp_performance communication_performance -d $folder ${COMMAND_ARGUMENTS[i]}
i=$i+1
echo
done

popd
}

show_results()
{
set -e
pushd $out_dir > /dev/null

echo -e "\e[34mThe generated data will be posprocessed an showed.\e[39m"
echo

i=0
for folder in "${TEST_FOLDERS[@]}"
do
echo "Next configuration to be posprocessed:"
echo -e "\t\t${COMMAND_ARGUMENTS[i]}"
read -p "Press enter to posprocess and plot the results."
echo
ros2 run rclcpp_performance posprocess_logging -d $folder
i=$i+1
done

popd
}

main "$@"
15 changes: 14 additions & 1 deletion rclcpp_performance/src/communication_performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class PublisherConstantRate
uint64_t publisher_id,
std::string base_dir,
uint64_t number_of_messages_to_send,
uint64_t message_length,
PeriodT period,
bool use_unique_message,
rmw_qos_profile_t qos_profile = rmw_qos_profile_default) :
Expand All @@ -44,6 +45,7 @@ class PublisherConstantRate
// Note(ivanpauno): msg type could be changed, to try the different publish methods.
shared_msg_ = std::make_shared<rclcpp_performance::msg::MatchingPublisher>();
shared_msg_->publisher_id = publisher_id;
shared_msg_->data.resize(message_length);
shared_msg_->message_id = 0;

std::stringstream ss;
Expand Down Expand Up @@ -76,7 +78,7 @@ class PublisherConstantRate
};
timer_ = node->create_wall_timer(period, callback);
} else {
auto callback = [this]() -> void
auto callback = [this, message_length]() -> void
{
if (this->number_of_messages_to_send_) {
// First create a shared message and copy the data.
Expand All @@ -85,6 +87,7 @@ class PublisherConstantRate
std::make_unique<rclcpp_performance::msg::MatchingPublisher>();
unique_msg->publisher_id = this->shared_msg_->publisher_id;
unique_msg->message_id = this->shared_msg_->message_id;
unique_msg->data.resize(message_length);
this->logging_file_ << unique_msg->message_id << ", "
<< std::chrono::duration_cast<TimestampT>(
std::chrono::system_clock::now().time_since_epoch()).count()
Expand Down Expand Up @@ -194,6 +197,7 @@ class PerformanceTestNode : public rclcpp::Node
std::string base_dir,
uint64_t number_of_pub_sub,
uint64_t number_of_messages,
uint64_t message_length,
PeriodT publish_period,
bool use_unique_message) :
Node(node_name, node_options)
Expand All @@ -216,6 +220,7 @@ class PerformanceTestNode : public rclcpp::Node
i,
base_dir,
number_of_messages,
message_length,
publish_period,
use_unique_message);
publishers_.push_back(pub);
Expand All @@ -234,6 +239,7 @@ int main(int argc, char ** argv)
PeriodT period = PeriodT(100);
uint64_t number_of_messages = 1000;
uint64_t number_of_publishers = 100;
uint64_t message_length = 100;
rclcpp::NodeOptions node_options;
bool use_unique_message = false;

Expand Down Expand Up @@ -265,6 +271,12 @@ int main(int argc, char ** argv)
iss >> number_of_publishers;
}

cli_option = rcutils_cli_get_option(argv, argv + argc, "-l");
if (nullptr != cli_option) {
std::istringstream iss(cli_option);
iss >> message_length;
}

bool option = rcutils_cli_option_exist(argv, argv + argc, "-intra");
if (option) {
node_options.use_intra_process_comms(true);
Expand All @@ -283,6 +295,7 @@ int main(int argc, char ** argv)
base_dir,
number_of_publishers, //number of publishers/subscriptions
number_of_messages, // number of messages to be send
message_length, // message length in bytes
period, // Publish period
use_unique_message); //use unique message or shared

Expand Down

0 comments on commit 7842991

Please sign in to comment.