Skip to content

Commit 841e206

Browse files
committed
Added variable message length. Added script for reproduce tests made.
Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
1 parent 2bdf933 commit 841e206

4 files changed

Lines changed: 170 additions & 2 deletions

File tree

rclcpp_performance/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ament_export_dependencies(rosidl_default_runtime)
3939
ament_package()
4040

4141
install(
42-
PROGRAMS scripts/posprocess_logging
42+
PROGRAMS scripts/posprocess_logging scripts/performance_test
4343
DESTINATION lib/${PROJECT_NAME}
4444
)
4545

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
uint64 publisher_id
22
uint64 message_id
3+
uint8[] data
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#!/bin/bash
2+
3+
TEST_FOLDERS=(
4+
"test_intra_shared_10ms_n100_m10000_l100000"
5+
"test_inter_shared_10ms_n100_m10000_l100000"
6+
"test_intra_unique_10ms_n100_m10000_l100000"
7+
"test_inter_unique_10ms_n100_m10000_l100000"
8+
9+
"test_intra_shared_10ms_n10_m10000_l1000000"
10+
"test_inter_shared_10ms_n10_m10000_l1000000"
11+
"test_intra_unique_10ms_n10_m10000_l1000000"
12+
"test_inter_unique_10ms_n10_m10000_l1000000"
13+
14+
"test_intra_shared_10ms_n1_m10000_l10000000"
15+
"test_inter_shared_10ms_n1_m10000_l10000000"
16+
"test_intra_unique_10ms_n1_m10000_l10000000"
17+
"test_inter_unique_10ms_n1_m10000_l10000000"
18+
19+
# These tests below suffers of starvation
20+
# "test_intra_shared_10ms_n5_m100_l10000000"
21+
# "test_inter_shared_10ms_n5_m100_l10000000"
22+
)
23+
24+
COMMAND_ARGUMENTS=(
25+
"-p 10 -n 100 -m 10000 -l 100000 -intra"
26+
"-p 10 -n 100 -m 10000 -l 100000"
27+
"-p 10 -n 100 -m 10000 -l 100000 -intra -unique"
28+
"-p 10 -n 100 -m 10000 -l 100000 -unique"
29+
30+
"-p 10 -n 10 -m 10000 -l 1000000 -intra"
31+
"-p 10 -n 10 -m 10000 -l 1000000"
32+
"-p 10 -n 10 -m 10000 -l 1000000 -intra -unique"
33+
"-p 10 -n 10 -m 10000 -l 1000000 -unique"
34+
35+
"-p 10 -n 1 -m 10000 -l 10000000 -intra"
36+
"-p 10 -n 1 -m 10000 -l 10000000"
37+
"-p 10 -n 1 -m 10000 -l 10000000 -intra -unique"
38+
"-p 10 -n 1 -m 10000 -l 10000000 -unique"
39+
40+
# "-p 10 -n 5 -m 10000 -l 10000000 -intra"
41+
# "-p 10 -n 5 -m 10000 -l 10000000"
42+
)
43+
44+
45+
DESCRIPTION=(
46+
"Intraprocess, shared publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
47+
"Interprocess, shared publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
48+
"Intraprocess, unique publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
49+
"Interprocess, unique publish, 100 pubs/subs, 10000 messages, 100000 bytes length, 10ms period."
50+
51+
"Intraprocess, shared publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
52+
"Interprocess, shared publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
53+
"Intraprocess, unique publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
54+
"Interprocess, unique publish, 10 pubs/subs, 10000 messages, 1000000 bytes length, 10ms period."
55+
56+
"Intraprocess, shared publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
57+
"Interprocess, shared publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
58+
"Intraprocess, unique publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
59+
"Interprocess, unique publish, 1 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
60+
61+
# "Intraprocess, shared publish, 5 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
62+
# "Interprocess, shared publish, 5 pubs/subs, 10000 messages, 10000000 bytes length, 10ms period."
63+
)
64+
65+
main()
66+
{
67+
set -e
68+
parse_arguments "$@"
69+
if [[ $skip -eq 0 ]]; then
70+
run_tests
71+
fi
72+
show_results
73+
}
74+
75+
parse_arguments()
76+
{
77+
set -e
78+
out_dir="logs"
79+
skip=0
80+
81+
while [[ $# > 0 ]]
82+
do
83+
key="$1"
84+
case $key in
85+
-d|--dir)
86+
out_dir="$2"
87+
shift # past argument
88+
;;
89+
-s|--skip)
90+
skip=1
91+
;;
92+
-h|--help)
93+
print_help
94+
;;
95+
*)
96+
print_help
97+
;;
98+
esac
99+
shift # past argument or value
100+
done
101+
}
102+
103+
print_help()
104+
{
105+
echo "Usage: $0 -d OUTPUT_DIR [--skip]"
106+
echo "The logs file will be generated inside OUTPUT_DIR"
107+
echo "Options:"
108+
echo -e "\t\t-s|--skip: Only posprocess and show results, skip running tests."
109+
exit 0
110+
}
111+
112+
run_tests()
113+
{
114+
set -e
115+
mkdir -p $out_dir
116+
pushd $out_dir > /dev/null
117+
118+
i=0
119+
for folder in "${TEST_FOLDERS[@]}"
120+
do
121+
echo -e "\e[34mRunning performance test with the following configuration:\e[39m"
122+
echo -e "\e[34m\t\t${COMMAND_ARGUMENTS[i]}\e[39m"
123+
mkdir -p $folder
124+
ros2 run rclcpp_performance communication_performance -d $folder ${COMMAND_ARGUMENTS[i]}
125+
i=$i+1
126+
echo
127+
done
128+
129+
popd
130+
}
131+
132+
show_results()
133+
{
134+
set -e
135+
pushd $out_dir > /dev/null
136+
137+
echo -e "\e[34mThe generated data will be posprocessed an showed.\e[39m"
138+
echo
139+
140+
i=0
141+
for folder in "${TEST_FOLDERS[@]}"
142+
do
143+
echo "Next configuration to be posprocessed:"
144+
echo -e "\t\t${COMMAND_ARGUMENTS[i]}"
145+
read -p "Press enter to posprocess and plot the results."
146+
echo
147+
ros2 run rclcpp_performance posprocess_logging -d $folder
148+
i=$i+1
149+
done
150+
151+
popd
152+
}
153+
154+
main "$@"

rclcpp_performance/src/communication_performance.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class PublisherConstantRate
3636
uint64_t publisher_id,
3737
std::string base_dir,
3838
uint64_t number_of_messages_to_send,
39+
uint64_t message_length,
3940
PeriodT period,
4041
bool use_unique_message,
4142
rmw_qos_profile_t qos_profile = rmw_qos_profile_default) :
@@ -44,6 +45,7 @@ class PublisherConstantRate
4445
// Note(ivanpauno): msg type could be changed, to try the different publish methods.
4546
shared_msg_ = std::make_shared<rclcpp_performance::msg::MatchingPublisher>();
4647
shared_msg_->publisher_id = publisher_id;
48+
shared_msg_->data.resize(message_length);
4749
shared_msg_->message_id = 0;
4850

4951
std::stringstream ss;
@@ -76,7 +78,7 @@ class PublisherConstantRate
7678
};
7779
timer_ = node->create_wall_timer(period, callback);
7880
} else {
79-
auto callback = [this]() -> void
81+
auto callback = [this, message_length]() -> void
8082
{
8183
if (this->number_of_messages_to_send_) {
8284
// First create a shared message and copy the data.
@@ -85,6 +87,7 @@ class PublisherConstantRate
8587
std::make_unique<rclcpp_performance::msg::MatchingPublisher>();
8688
unique_msg->publisher_id = this->shared_msg_->publisher_id;
8789
unique_msg->message_id = this->shared_msg_->message_id;
90+
unique_msg->data.resize(message_length);
8891
this->logging_file_ << unique_msg->message_id << ", "
8992
<< std::chrono::duration_cast<TimestampT>(
9093
std::chrono::system_clock::now().time_since_epoch()).count()
@@ -194,6 +197,7 @@ class PerformanceTestNode : public rclcpp::Node
194197
std::string base_dir,
195198
uint64_t number_of_pub_sub,
196199
uint64_t number_of_messages,
200+
uint64_t message_length,
197201
PeriodT publish_period,
198202
bool use_unique_message) :
199203
Node(node_name, node_options)
@@ -216,6 +220,7 @@ class PerformanceTestNode : public rclcpp::Node
216220
i,
217221
base_dir,
218222
number_of_messages,
223+
message_length,
219224
publish_period,
220225
use_unique_message);
221226
publishers_.push_back(pub);
@@ -234,6 +239,7 @@ int main(int argc, char ** argv)
234239
PeriodT period = PeriodT(100);
235240
uint64_t number_of_messages = 1000;
236241
uint64_t number_of_publishers = 100;
242+
uint64_t message_length = 100;
237243
rclcpp::NodeOptions node_options;
238244
bool use_unique_message = false;
239245

@@ -265,6 +271,12 @@ int main(int argc, char ** argv)
265271
iss >> number_of_publishers;
266272
}
267273

274+
cli_option = rcutils_cli_get_option(argv, argv + argc, "-l");
275+
if (nullptr != cli_option) {
276+
std::istringstream iss(cli_option);
277+
iss >> message_length;
278+
}
279+
268280
bool option = rcutils_cli_option_exist(argv, argv + argc, "-intra");
269281
if (option) {
270282
node_options.use_intra_process_comms(true);
@@ -283,6 +295,7 @@ int main(int argc, char ** argv)
283295
base_dir,
284296
number_of_publishers, //number of publishers/subscriptions
285297
number_of_messages, // number of messages to be send
298+
message_length, // message length in bytes
286299
period, // Publish period
287300
use_unique_message); //use unique message or shared
288301

0 commit comments

Comments
 (0)